Esempio n. 1
0
        public void StartProcessing(string command, string serialnumber)
        {
            if (command.StartsWith("adb"))
            {
                if (AdbDeviceWatcher.GetConnectedAdbDevices() > 0 || command.EndsWith("help") ||
                    command.EndsWith("version") || command.StartsWith("adb connect") ||
                    command.StartsWith("adb disconnect"))
                {
                    StopProcessing();
                    Thread.Sleep(50);
                    CommandExecutionStarted?.Invoke();
                    GetProcess.StandardInput.WriteLine(CommandParser(command, serialnumber));
                }
                else
                {
                    MessageBox.Show(@"No device connected. Please connect a device for adb commands.",
                                    @"Error - No Device Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else if (command.StartsWith("cls"))
            {
                ClearConsole?.Invoke();
            }

            else
            {
                StopProcessing();
                Thread.Sleep(50);
                CommandExecutionStarted?.Invoke();
                GetProcess.StandardInput.WriteLine(CommandParser(command, serialnumber));
            }
        }
Esempio n. 2
0
        public static string StartProcessingInThread(string command, string serialnumber)
        {
            if (command.StartsWith("adb"))
            {
                if (AdbDeviceWatcher.GetConnectedAdbDevices() > 0 || command.EndsWith("help") ||
                    command.EndsWith("version") || command.StartsWith("adb connect") ||
                    command.StartsWith("adb disconnect"))
                {
                    var output = "";

                    var t = new Thread(() => { output = StartProcessingReadToEnd(command, serialnumber); })
                    {
                        IsBackground = true
                    };

                    t.Start();

                    while (t.IsAlive)
                    {
                        Application.DoEvents();
                    }

                    return(output);
                }
                else
                {
                    return(null);
                }
            }

            {
                var output = "";

                var t = new Thread(() => { output = StartProcessingReadToEnd(command, serialnumber); })
                {
                    IsBackground = true
                };

                t.Start();

                while (t.IsAlive)
                {
                    Application.DoEvents();
                }

                return(output);
            }
        }