Example #1
0
 public void Delay(int value)
 {
     if (LogDelay)
     {
         LogCommand?.Invoke($"Delay {value}ms");
     }
     Task.Delay(value, CancellationToken).Wait();
 }
Example #2
0
 public string AdbCommandCmd(string command, int timeout)
 {
     CancellationToken.ThrowIfCancellationRequested();
     if (IsLd)
     {
         throw new NotSupportedException(command);
     }
     else
     {
         string adbLocation = string.IsNullOrEmpty(adbPath) ? AdbPath : adbPath;
         string commands    = string.IsNullOrEmpty(DeviceId) ? command : $"-s {DeviceId} {command}";
         LogCommand?.Invoke(commands);
         using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(timeout);
         using (CancellationToken.Register(() => cancellationTokenSource.Cancel()))
         {
             return(ExecuteCommandCmd(commands, cancellationTokenSource.Token, adbLocation));
         }
     }
 }
Example #3
0
 public string AdbCommand(string command, int timeout)
 {
     CancellationToken.ThrowIfCancellationRequested();
     if (IsLd)
     {
         using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(timeout);
         using (CancellationToken.Register(() => cancellationTokenSource.Cancel()))
         {
             return(LdPlayer.LdPlayer.AdbCommand(DeviceId, command, cancellationTokenSource.Token));
         }
     }
     else
     {
         string adbLocation = string.IsNullOrEmpty(adbPath) ? AdbPath : adbPath;
         LogCommand?.Invoke("adb " + command);
         string commands = string.IsNullOrEmpty(DeviceId) ? command : $"-s {DeviceId} {command}";
         using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(timeout);
         using (CancellationToken.Register(() => cancellationTokenSource.Cancel()))
         {
             return(ExecuteCommand(commands, cancellationTokenSource.Token, adbLocation));
         }
     }
 }