public void ShowDialog() { RunTask(); window.Canceld += delegate { Canceld?.Invoke(this, EventArgs.Empty); }; window.ShowDialog(); #if DEBUG ThreadInvoker.BackInvoke(() => { System.Threading.Thread.Sleep(1000); for (int i = 0; i < 2; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } }); #endif }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { this.CancellationPending = true; Canceld?.Invoke(this, EventArgs.Empty); }