Skip to content

Commit

Permalink
Remove unused methods of Extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Oct 24, 2023
1 parent e688bff commit dd595b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/DeviceMonitor.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/DeviceMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
28 changes: 6 additions & 22 deletions AdvancedSharpAdbClient/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,6 @@ public static Task Delay(int dueTime, CancellationToken cancellationToken = defa
#endif
.Delay(dueTime, cancellationToken);

/// <summary>
/// Queues the specified work to run on the thread pool and returns a proxy for the task returned by <paramref name="function"/>.
/// </summary>
/// <param name="function">The work to execute asynchronously.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work if it has not yet started.</param>
/// <returns>A task that represents a proxy for the task returned by <paramref name="function"/>.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="function"/> parameter was <see langword="null"/>.</exception>
/// <remarks>For information on handling exceptions thrown by task operations, see <see href="https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/exception-handling-task-parallel-library">Exception Handling</see>.</remarks>
public static Task Run(Action function, CancellationToken cancellationToken = default) =>
#if NETFRAMEWORK && !NET45_OR_GREATER
TaskEx
#else
Task
#endif
.Run(function, cancellationToken);

/// <summary>
/// Queues the specified work to run on the thread pool and returns a proxy for the <see cref="Task{TResult}"/>
/// returned by function. A cancellation token allows the work to be cancelled if it has not yet started.
Expand Down Expand Up @@ -238,10 +222,10 @@ public static Task<TResult[]> WhenAll<TResult>(IEnumerable<Task<TResult>> tasks)
/// TResult parameter contains the next line from the text reader, or is null if
/// all of the characters have been read.</returns>
public static Task<string?> ReadLineAsync(this TextReader reader, CancellationToken cancellationToken) =>
#if !NET35
reader.ReadLineAsync();
#else
#if NET35
Run(reader.ReadLine, cancellationToken);
#else
reader.ReadLineAsync();
#endif

/// <summary>
Expand All @@ -253,10 +237,10 @@ public static Task<TResult[]> WhenAll<TResult>(IEnumerable<Task<TResult>> tasks)
/// parameter contains a string with the characters from the current position to
/// the end of the stream.</returns>
public static Task<string> ReadToEndAsync(this TextReader reader, CancellationToken cancellationToken) =>
#if !NET35
reader.ReadToEndAsync();
#else
#if NET35
Run(reader.ReadToEnd, cancellationToken);
#else
reader.ReadToEndAsync();
#endif
#endif
#endif
Expand Down

0 comments on commit dd595b4

Please sign in to comment.