Beispiel #1
0
 public MainWindow()
 {
     InitializeComponent();
     _viewModel       = ((ViewModelLocator)Application.Current.Resources["Locator"]).Main;
     this.DataContext = _viewModel;
     this.Logo.HeaderSubtitle.Text = "HOME";
     this.Loaded += delegate
     {
         RefreshAdb.Command.Execute(this.AdbDevices);
         RefreshFastboot.Command.Execute(this.FastbootDevices);
     };
     this.Closing += delegate
     {
         _viewModel.Cleanup();
         FastbootTools.Kill();
         AdbTools.KillAdb();
     };
     this.Closed += delegate { Application.Current.Shutdown(0); };
 }
        public static void Kill(object parameter)
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += async(sender, args) =>
            {
                var textBlock = parameter as TextBlock;
                if (textBlock != null)
                {
                    await textBlock.Dispatcher.InvokeAsync(async() =>
                    {
                        FastbootTools.Kill();
                        await textBlock.Dispatcher.InvokeAsync(() => textBlock.Text = "FASTBOOT KILLED");
                    });
                }
            };
            worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
            worker.RunWorkerAsync();
        }