public void Delay(int value) { if (LogDelay) { LogCommand?.Invoke($"Delay {value}ms"); } Task.Delay(value, CancellationToken).Wait(); }
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)); } } }
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)); } } }