public DispatcherSample() { InitializeComponent(); var d = new DerivedObject(); d.DoSomething(); }
private async void DispatcherButton_Click(object sender, RoutedEventArgs e) { var d = new DerivedObject(); await Task.Run(async() => { if (d.CheckAccess() == false) { await d.Dispatcher.InvokeAsync(() => d.DoSomething()); } }); }
private async void NGButton_Click(object sender, RoutedEventArgs e) { var d = new DerivedObject(); try { await Task.Run(() => d.DoSomething()); } catch { MessageBox.Show("例外"); } }
private void OKButton_Click(object sender, RoutedEventArgs e) { var d = new DerivedObject(); d.DoSomething(); }