UIをフリーズせずに、バックグラウンドでアクションを実行しようとしています。
もちろん、これにはBackgroundWorkerを使用できます。
ただし、タスクAPIのみで実行したいと思います。
私は試した:
async void OnTestLoaded(object sender, RoutedEventArgs e)
{
await LongOperation();
}
// It freezes the UI
と
async void OnTestLoaded(object sender, RoutedEventArgs e)
{
var task = Task.Run(()=> LongOperation());
task.Wait();
}
// It freezes the UI
では、BackgroundWorkerに戻る必要がありますか?または、タスクのみを使用するソリューションはありますか?