コード例 #1
0
        public DispatcherSample()
        {
            InitializeComponent();

            var d = new DerivedObject();

            d.DoSomething();
        }
コード例 #2
0
 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());
         }
     });
 }
コード例 #3
0
        private async void NGButton_Click(object sender, RoutedEventArgs e)
        {
            var d = new DerivedObject();

            try
            {
                await Task.Run(() => d.DoSomething());
            }
            catch
            {
                MessageBox.Show("例外");
            }
        }
コード例 #4
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            var d = new DerivedObject();

            d.DoSomething();
        }