Skip to content

Commit

Permalink
Added Task Extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII committed Aug 14, 2018
1 parent 4e0edf8 commit 2ff29cb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rocket.Surgery.Extensions.T
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rocket.Surgery.Linq.Extensions", "src\Linq.Extensions\Rocket.Surgery.Linq.Extensions.csproj", "{6244458A-DE05-4BB0-AE05-96647A364AF4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rocket.Surgery.Task.Extensions", "src\Task.Extensions\Rocket.Surgery.Task.Extensions.csproj", "{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -103,6 +105,18 @@ Global
{6244458A-DE05-4BB0-AE05-96647A364AF4}.Release|x64.Build.0 = Release|Any CPU
{6244458A-DE05-4BB0-AE05-96647A364AF4}.Release|x86.ActiveCfg = Release|Any CPU
{6244458A-DE05-4BB0-AE05-96647A364AF4}.Release|x86.Build.0 = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|x64.ActiveCfg = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|x64.Build.0 = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|x86.ActiveCfg = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Debug|x86.Build.0 = Debug|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|Any CPU.Build.0 = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|x64.ActiveCfg = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|x64.Build.0 = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|x86.ActiveCfg = Release|Any CPU
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -112,6 +126,7 @@ Global
{BA66981A-5F0B-45DD-A2C3-0E3100A2737F} = {52F62811-7776-42E4-921F-E1F9202F8074}
{CD3EA4F6-17C7-4BE6-838A-097B90E6A37F} = {F2329C11-7A3F-4D18-A665-6FA91A922DBF}
{6244458A-DE05-4BB0-AE05-96647A364AF4} = {52F62811-7776-42E4-921F-E1F9202F8074}
{CF47AAEF-8D26-49E8-BDD0-E5080B66C7A7} = {52F62811-7776-42E4-921F-E1F9202F8074}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7EF3BE50-98BC-4A67-A514-EF6078B1DA37}
Expand Down
10 changes: 10 additions & 0 deletions src/Task.Extensions/Rocket.Surgery.Task.Extensions.csproj
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>
35 changes: 35 additions & 0 deletions src/Task.Extensions/TaskExtensions.cs
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);
}
}
}

0 comments on commit 2ff29cb

Please sign in to comment.