public ProcessStream WaitForGame(Process process) { using (var cancellationTokenSource = new CancellationTokenSource()) { var task = Task.Run(async() => { _foundStream = await Pcsx2MemoryService.CreateStreamFromPcsx2Process(process, cancellationTokenSource.Token); // If the search ends, ask to close the current window dialog Application.Current.Dispatcher.Invoke(() => { if (_foundStream == null && !cancellationTokenSource.Token.IsCancellationRequested) { MessageBox.Show( "The loaded game in PCSX2 is not supported.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Close(); }); }, cancellationTokenSource.Token); ShowDialog(); // If the search is still running, ask to it to terminate ASAP. cancellationTokenSource.Cancel(); } return(_foundStream); }
public ProcessStream WaitForGame(Process process) { using (var cancellationTokenSource = new CancellationTokenSource()) { var task = Task.Run(async() => { _foundStream = await Pcsx2MemoryService.CreateStreamFromPcsx2Process(process, cancellationTokenSource.Token); // If the search ends, ask to close the current window dialog Application.Current.Dispatcher.Invoke(() => Close()); }, cancellationTokenSource.Token); ShowDialog(); // If the search is still running, ask to it to terminate ASAP. cancellationTokenSource.Cancel(); } return(_foundStream); }