Struct NonDisposableTask
Used to convert a Task into an awaitable that that does not
implement IDisposable. This is useful for avoiding confusion
and hard to debug problems when async methods return an IDisposable
intended to be referenced in a using
statement. It is very easy to forget
the await
keyword in this situation and because Task
also implements IDisposable, there will be no compiler error
or warning. Wrapping the task with this structure addresses this.
Namespace: Neon.Tasks
Assembly: Neon.Common.dll
Syntax
public struct NonDisposableTask
Constructors
NonDisposableTask(Task)
Constructor.
Declaration
public NonDisposableTask(Task task)
Parameters
Type | Name | Description |
---|---|---|
Task | task | The task being wrapped. |
Methods
GetAwaiter()
Returns the task's awaiter.
Declaration
public TaskAwaiter GetAwaiter()
Returns
Type | Description |
---|---|
TaskAwaiter |