diff --git a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs index 184f2f92..4f4af966 100644 --- a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs +++ b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs @@ -38,7 +38,7 @@ public virtual async Task StartAsync(CancellationToken cancellationToken = defau { _ = firstDeviceListParsed.Reset(); - monitorTask = Extensions.Run(() => DeviceMonitorLoopAsync(monitorTaskCancellationTokenSource.Token), cancellationToken); + monitorTask = DeviceMonitorLoopAsync(monitorTaskCancellationTokenSource.Token); // Wait for the worker thread to have read the first list of devices. _ = await Extensions.Run(firstDeviceListParsed.WaitOne, cancellationToken).ConfigureAwait(false); diff --git a/AdvancedSharpAdbClient/DeviceMonitor.cs b/AdvancedSharpAdbClient/DeviceMonitor.cs index 9f5afc1f..a982a45b 100644 --- a/AdvancedSharpAdbClient/DeviceMonitor.cs +++ b/AdvancedSharpAdbClient/DeviceMonitor.cs @@ -153,7 +153,7 @@ public virtual void Start() { _ = firstDeviceListParsed.Reset(); - monitorTask = Extensions.Run(() => DeviceMonitorLoopAsync(monitorTaskCancellationTokenSource.Token)); + monitorTask = DeviceMonitorLoopAsync(monitorTaskCancellationTokenSource.Token); // Wait for the worker thread to have read the first list of devices. _ = firstDeviceListParsed.WaitOne(); diff --git a/AdvancedSharpAdbClient/Extensions/Extensions.cs b/AdvancedSharpAdbClient/Extensions/Extensions.cs index 35fb616e..90e265d5 100644 --- a/AdvancedSharpAdbClient/Extensions/Extensions.cs +++ b/AdvancedSharpAdbClient/Extensions/Extensions.cs @@ -167,22 +167,6 @@ public static Task Delay(int dueTime, CancellationToken cancellationToken = defa #endif .Delay(dueTime, cancellationToken); - /// - /// Queues the specified work to run on the thread pool and returns a proxy for the task returned by . - /// - /// The work to execute asynchronously. - /// A cancellation token that can be used to cancel the work if it has not yet started. - /// A task that represents a proxy for the task returned by . - /// The parameter was . - /// For information on handling exceptions thrown by task operations, see Exception Handling. - public static Task Run(Action function, CancellationToken cancellationToken = default) => -#if NETFRAMEWORK && !NET45_OR_GREATER - TaskEx -#else - Task -#endif - .Run(function, cancellationToken); - /// /// Queues the specified work to run on the thread pool and returns a proxy for the /// returned by function. A cancellation token allows the work to be cancelled if it has not yet started. @@ -238,10 +222,10 @@ public static Task WhenAll(IEnumerable> tasks) /// TResult parameter contains the next line from the text reader, or is null if /// all of the characters have been read. public static Task ReadLineAsync(this TextReader reader, CancellationToken cancellationToken) => -#if !NET35 - reader.ReadLineAsync(); -#else +#if NET35 Run(reader.ReadLine, cancellationToken); +#else + reader.ReadLineAsync(); #endif /// @@ -253,10 +237,10 @@ public static Task WhenAll(IEnumerable> tasks) /// parameter contains a string with the characters from the current position to /// the end of the stream. public static Task ReadToEndAsync(this TextReader reader, CancellationToken cancellationToken) => -#if !NET35 - reader.ReadToEndAsync(); -#else +#if NET35 Run(reader.ReadToEnd, cancellationToken); +#else + reader.ReadToEndAsync(); #endif #endif #endif