private async void NextButton_Click(object sender, RoutedEventArgs e) { if (page.Validate()) { if (currentPage == 11 || currentPage == 21 || currentPage == 31) { Task run = null; if (currentPage == 11) { run = new Task(() => Business.StartMuxe()); } if (currentPage == 21) { run = new Task(() => Business.StartMerge()); } if (currentPage == 31) { run = new Task(() => Business.StartSplit()); } await WorkingWindow.InstanceAsync(this, run); CurrentPage = 1; } CurrentPage++; } }
public async static Task InstanceAsync(Window owner, Task worker) { WorkingWindow W = new WorkingWindow(); W.Owner = owner; CancellationToken token = new CancellationToken(); Task InitWinTask = Task.Factory.StartNew( () => W.ShowDialog(), token, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); worker.Start(); await worker; W.Close(); await InitWinTask; }