Skip to content

Commit

Permalink
Async extensions (NoCtx)
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingpie committed Jul 14, 2024
1 parent 4db65ef commit 69c1282
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/10-Core/Wtq/Utils/SystemExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Runtime.CompilerServices;

namespace Wtq.Utils;

public static class SystemExtensions
{
[SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "MvdO: Whether or not to await is up to the caller.")]
public static ConfiguredTaskAwaitable NoCtx(this Task task)
{
ArgumentNullException.ThrowIfNull(task);

return task.ConfigureAwait(false);
}

[SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "MvdO: Whether or not to await is up to the caller.")]
public static ConfiguredTaskAwaitable<TResult> NoCtx<TResult>(this Task<TResult> task)
{
ArgumentNullException.ThrowIfNull(task);

return task.ConfigureAwait(false);
}
}

0 comments on commit 69c1282

Please sign in to comment.