Bug description
ValueTask instances can be backed by pooled objects. If these tasks are not awaited, the pooled objects can get discarded, negatively impacting application efficiency.
Repro steps
Expected behavior
The Forget extension methods behave as though the task is awaited. @stephentoub may be able to help identify the most efficient approach here.
Actual behavior
The task is not awaited.
|
/// <summary> |
|
/// Consumes a task and doesn't do anything with it. Useful for fire-and-forget calls to async methods within async methods. |
|
/// </summary> |
|
/// <param name="task">The task whose result is to be ignored.</param> |
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "task")] |
|
public static void Forget(this ValueTask task) |
|
{ |
|
} |
|
|
|
/// <summary> |
|
/// Consumes a task and doesn't do anything with it. Useful for fire-and-forget calls to async methods within async methods. |
|
/// </summary> |
|
/// <typeparam name="T">The type of value produced by the <paramref name="task"/>.</typeparam> |
|
/// <param name="task">The task whose result is to be ignored.</param> |
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "task")] |
|
public static void Forget<T>(this ValueTask<T> task) |
|
{ |
|
} |
Bug description
ValueTask instances can be backed by pooled objects. If these tasks are not awaited, the pooled objects can get discarded, negatively impacting application efficiency.
Repro steps
Expected behavior
The
Forgetextension methods behave as though the task is awaited. @stephentoub may be able to help identify the most efficient approach here.Actual behavior
The task is not awaited.
vs-threading/src/Microsoft.VisualStudio.Threading/TplExtensions.cs
Lines 261 to 278 in 8085d15