TplExtensions.ToApm Method (Task, AsyncCallback, Object)
Converts a TPL task to the Asynchronous Programming Model (APM) Begin-End pattern.
Namespace: Microsoft.VisualStudio.Threading
Assembly: Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function ToApm ( _
task As Task, _
callback As AsyncCallback, _
state As Object _
) As Task
public static Task ToApm(
this Task task,
AsyncCallback callback,
Object state
)
[ExtensionAttribute]
public:
static Task^ ToApm(
Task^ task,
AsyncCallback^ callback,
Object^ state
)
static member ToApm :
task:Task *
callback:AsyncCallback *
state:Object -> Task
public static function ToApm(
task : Task,
callback : AsyncCallback,
state : Object
) : Task
Parameters
task
Type: System.Threading.Tasks.TaskThe task that came from the asynchronous method.
callback
Type: System.AsyncCallbackThe optional callback to invoke when the task is completed.
state
Type: System.ObjectThe state object provided by the caller of the Begin method.
Return Value
Type: System.Threading.Tasks.Task
A Task<TResult> (that implements IAsyncResult that should be returned from the Begin method.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Task. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.