TaskFactory<TResult>.FromAsync 方法

定義

建立新的工作執行個體。Creates a task instance.

多載

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions, TaskScheduler)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

public:
 System::Threading::Tasks::Task<TResult> ^ FromAsync(IAsyncResult ^ asyncResult, Func<IAsyncResult ^, TResult> ^ endMethod);
public System.Threading.Tasks.Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult,TResult> endMethod);
member this.FromAsync : IAsyncResult * Func<IAsyncResult, 'Result> -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult)) As Task(Of TResult)

參數

asyncResult
IAsyncResult

IAsyncResult,完成時會觸發 endMethod 處理作業。The IAsyncResult whose completion should trigger the processing of the endMethod.

endMethod
Func<IAsyncResult,TResult>

函式委派,會處理已完成的 asyncResultThe function delegate that processes the completed asyncResult.

傳回

表示非同步作業的 Task<TResult>A Task<TResult> that represents the asynchronous operation.

例外狀況

asyncResult 引數為 nullThe asyncResult argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

另請參閱

FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, System::Object ^ state);
public System.Threading.Tasks.Task<TResult> FromAsync (Func<AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, object state);
member this.FromAsync : Func<AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * obj -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), state As Object) As Task(Of TResult)

參數

beginMethod
Func<AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

public:
 System::Threading::Tasks::Task<TResult> ^ FromAsync(IAsyncResult ^ asyncResult, Func<IAsyncResult ^, TResult> ^ endMethod, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult,TResult> endMethod, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : IAsyncResult * Func<IAsyncResult, 'Result> * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult), creationOptions As TaskCreationOptions) As Task(Of TResult)

參數

asyncResult
IAsyncResult

IAsyncResult,完成時會觸發 endMethod 處理作業。The IAsyncResult whose completion should trigger the processing of the endMethod.

endMethod
Func<IAsyncResult,TResult>

函式委派,會處理已完成的 asyncResultThe function delegate that processes the completed asyncResult.

creationOptions
TaskCreationOptions

其中一個列舉值,這些值會控制已建立之工作的行為。One of the enumeration values that controls the behavior of the created task.

傳回

代表非同步作業的工作。A task that represents the asynchronous operation.

例外狀況

asyncResult 引數為 nullThe asyncResult argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

creationOptions 引數指定了無效的值。The creationOptions argument specifies an invalid value.

另請參閱

FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync (Func<AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), state As Object, creationOptions As TaskCreationOptions) As Task(Of TResult)

參數

beginMethod
Func<AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

creationOptions
TaskCreationOptions

其中一個列舉值,這些值會控制已建立之工作的行為。One of the enumeration values that controls the behavior of the created task.

傳回

建立的 Task<TResult>,表示非同步作業。The created Task<TResult> that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

creationOptions 引數指定了無效的值。The creationOptions argument specifies an invalid value.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions, TaskScheduler)

建立工作,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a task that executes an end method function when a specified IAsyncResult completes.

public:
 System::Threading::Tasks::Task<TResult> ^ FromAsync(IAsyncResult ^ asyncResult, Func<IAsyncResult ^, TResult> ^ endMethod, System::Threading::Tasks::TaskCreationOptions creationOptions, System::Threading::Tasks::TaskScheduler ^ scheduler);
public System.Threading.Tasks.Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult,TResult> endMethod, System.Threading.Tasks.TaskCreationOptions creationOptions, System.Threading.Tasks.TaskScheduler scheduler);
member this.FromAsync : IAsyncResult * Func<IAsyncResult, 'Result> * System.Threading.Tasks.TaskCreationOptions * System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult), creationOptions As TaskCreationOptions, scheduler As TaskScheduler) As Task(Of TResult)

參數

asyncResult
IAsyncResult

IAsyncResult,完成時會觸發 endMethod 處理作業。The IAsyncResult whose completion should trigger the processing of the endMethod.

endMethod
Func<IAsyncResult,TResult>

函式委派,會處理已完成的 asyncResultThe function delegate that processes the completed asyncResult.

creationOptions
TaskCreationOptions

其中一個列舉值,這些值會控制已建立之工作的行為。One of the enumeration values that controls the behavior of the created task.

scheduler
TaskScheduler

工作排程器,用來排程可執行結束方法的工作。The task scheduler that is used to schedule the task that executes the end method.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

asyncResult 引數為 nullThe asyncResult argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

-或--or- scheduler 引數為 nullThe scheduler argument is null.

creationOptions 參數指定了無效的值。The creationOptions parameter specifies an invalid value.

另請參閱

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1, typename TArg2, typename TArg3>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, TArg2, TArg3, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, 'TArg2, 'TArg3, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * 'TArg2 * 'TArg3 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1, TArg2, TArg3) (beginMethod As Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, arg2 As TArg2, arg3 As TArg3, state As Object, creationOptions As TaskCreationOptions) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第二個引數類型。The type of the second argument passed to beginMethod delegate.

TArg2

傳遞至 beginMethod 委派的第三個引數類型。The type of the third argument passed to beginMethod delegate.

TArg3

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

arg2
TArg2

傳遞至 beginMethod 委派的第二個引數。The second argument passed to the beginMethod delegate.

arg3
TArg3

傳遞至 beginMethod 委派的第三個引數。The third argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

creationOptions
TaskCreationOptions

控制所建立工作之行為的物件。An object that controls the behavior of the created task.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

creationOptions 參數指定了無效的值。The creationOptions parameter specifies an invalid value.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1, typename TArg2, typename TArg3>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, TArg2, TArg3, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, System::Object ^ state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object state);
member this.FromAsync : Func<'TArg1, 'TArg2, 'TArg3, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * 'TArg2 * 'TArg3 * obj -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1, TArg2, TArg3) (beginMethod As Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, arg2 As TArg2, arg3 As TArg3, state As Object) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第二個引數類型。The type of the second argument passed to beginMethod delegate.

TArg2

傳遞至 beginMethod 委派的第三個引數類型。The type of the third argument passed to beginMethod delegate.

TArg3

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

arg2
TArg2

傳遞至 beginMethod 委派的第二個引數。The second argument passed to the beginMethod delegate.

arg3
TArg3

傳遞至 beginMethod 委派的第三個引數。The third argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1, typename TArg2>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, TArg2, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, TArg2 arg2, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, 'TArg2, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * 'TArg2 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1, TArg2) (beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, arg2 As TArg2, state As Object, creationOptions As TaskCreationOptions) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第二個引數類型。The type of the second argument passed to beginMethod delegate.

TArg2

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

arg2
TArg2

傳遞至 beginMethod 委派的第二個引數。The second argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

creationOptions
TaskCreationOptions

控制所建立 Task<TResult> 之行為的物件。An object that controls the behavior of the created Task<TResult>.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

creationOptions 參數指定了無效的值。The creationOptions parameter specifies an invalid value.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1, typename TArg2>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, TArg2, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, TArg2 arg2, System::Object ^ state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, object state);
member this.FromAsync : Func<'TArg1, 'TArg2, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * 'TArg2 * obj -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1, TArg2) (beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, arg2 As TArg2, state As Object) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第二個引數類型。The type of the second argument passed to beginMethod delegate.

TArg2

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

arg2
TArg2

傳遞至 beginMethod 委派的第二個引數。The second argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, System::Object ^ state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, object state);
member this.FromAsync : Func<'TArg1, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * obj -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1) (beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, state As Object) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object, TaskCreationOptions)

建立工作,這個項目代表一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

public:
generic <typename TArg1>
 System::Threading::Tasks::Task<TResult> ^ FromAsync(Func<TArg1, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Func<IAsyncResult ^, TResult> ^ endMethod, TArg1 arg1, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, AsyncCallback, obj, IAsyncResult> * Func<IAsyncResult, 'Result> * 'TArg1 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TArg1) (beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), arg1 As TArg1, state As Object, creationOptions As TaskCreationOptions) As Task(Of TResult)

類型參數

TArg1

傳遞至 beginMethod 委派的第一個引數類型。The type of the first argument passed to the beginMethod delegate.

參數

beginMethod
Func<TArg1,AsyncCallback,Object,IAsyncResult>

開始非同步作業的委派。The delegate that begins the asynchronous operation.

endMethod
Func<IAsyncResult,TResult>

結束非同步作業的委派。The delegate that ends the asynchronous operation.

arg1
TArg1

傳遞至 beginMethod 委派的第一個引數。The first argument passed to the beginMethod delegate.

state
Object

物件,包含 beginMethod 委派要使用的資料。An object containing data to be used by the beginMethod delegate.

creationOptions
TaskCreationOptions

其中一個列舉值,這些值會控制已建立之工作的行為。One of the enumeration values that controls the behavior of the created task.

傳回

建立的工作,代表非同步作業。The created task that represents the asynchronous operation.

例外狀況

beginMethod 引數為 nullThe beginMethod argument is null.

-或--or- endMethod 引數為 nullThe endMethod argument is null.

creationOptions 參數指定了無效的值。The creationOptions parameter specifies an invalid value.

備註

這個方法會擲回 beginMethod擲回的任何例外狀況。This method throws any exceptions thrown by the beginMethod. 在等候傳回的工作時,會擲回 endmethod 的例外狀況。Exceptions for endmethod are thrown when waiting on the returned task.

另請參閱

適用於