public static void Prepare(object parameter)
 {
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         var textBlock = parameter as TextBlock;
         if (textBlock != null)
             await textBlock.Dispatcher.InvokeAsync(async () =>
             {
                 Fastboot = new FastbootTools(textBlock);
                 await Fastboot.Prepare();
             });
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }
 public static void ExecuteReboot(object parameter)
 {
     SingleCommandParameters parameters = (SingleCommandParameters)parameter;
     Context = parameters.Context;
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         await Context.Dispatcher.InvokeAsync(() => { Fastboot = new FastbootTools(Context); });
         await Task.Run(async () => await Fastboot.Reboot(parameters.Bool));
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }
 public static void ExecuteListDevices(object parameter)
 {
     UIParameters parameters = (UIParameters)parameter;
     if (parameters != null)
     {
         Context = parameters.Context;
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += async (sender, args) =>
         {
             await Context.Dispatcher.InvokeAsync(async () =>
             {
                 Fastboot = new FastbootTools(Context);
                 await Fastboot.ListDevices(parameters.Context2, parameters.Bool);
             });
         };
         worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
         worker.RunWorkerAsync();
     }
 }
        public static void Execute2(object parameter)
        {
            ExecuteCommandParameters parameters = parameter as ExecuteCommandParameters;
            if (parameters != null)
            {
                Context = parameters.Context;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += async (sender, args) =>
                {
                    await Context.Dispatcher.InvokeAsync(async () =>
                    {
                        Fastboot = new FastbootTools(Context);
                        var cmds = new List<string>
                        {
                            parameters.Text,
                            parameters.Text2,
                            parameters.Text3,
                            parameters.Text4,
                            parameters.Text5,
                            parameters.Text6,
                            parameters.Text7,
                            parameters.Text8,
                            parameters.Text9,
                            parameters.Text10
                        };
                        await Fastboot.Execute(cmds, parameters.Bool);
                    });
                };
                worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
                worker.RunWorkerAsync();
            }

        }
        public static void Execute(object parameter)
        {
            TwoCommandParameters parameters = parameter as TwoCommandParameters;
            if (parameters != null)
            {
                Context = parameters.Context;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += async (sender, args) =>
                {
                    await Context.Dispatcher.InvokeAsync(async () =>
                    {
                        Fastboot = new FastbootTools(Context);
                        await Fastboot.Execute(parameters.Text, parameters.Bool);
                    });
                };
                worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
                worker.RunWorkerAsync();
            }

        }
 public static void FlashZip(object parameter)
 {
     TwoCommandParameters parameters = (TwoCommandParameters)parameter;
     Context = parameters.Context;
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         await Context.Dispatcher.InvokeAsync(async () =>
         {
             Fastboot = new FastbootTools(Context);
             await Fastboot.FlashZip(parameters.Text, parameters.Bool);
         });
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }