共用方式為


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

  • state
    Type: System.Object

    The 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

See Also

Reference

TplExtensions Class

ToApm Overload

Microsoft.VisualStudio.Threading Namespace