-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0edf8
commit 2ff29cb
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Reactive" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Reactive.Concurrency; | ||
using System.Runtime.CompilerServices; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Threading.Tasks | ||
{ | ||
public static class TaskExtensions | ||
{ | ||
/// <summary> | ||
/// Continues the <see cref="Task"/> return on any <see cref="IScheduler"/> context. | ||
/// </summary> | ||
/// <param name="this">The this.</param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException">this</exception> | ||
public static ConfiguredTaskAwaitable ContinueOnAnyContext(this Task @this) | ||
{ | ||
if (@this == null) throw new ArgumentNullException(nameof(@this)); | ||
return @this.ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Continues the <see cref="Task"/> return on any <see cref="IScheduler"/> context. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="this">The this.</param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException">this</exception> | ||
public static ConfiguredTaskAwaitable<T> ContinueOnAnyContext<T>(this Task<T> @this) | ||
{ | ||
if (@this == null) throw new ArgumentNullException(nameof(@this)); | ||
return @this.ConfigureAwait(false); | ||
} | ||
} | ||
} |