TaskFactory.FromAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
多載
FromAsync(IAsyncResult, Action<IAsyncResult>)
建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。
public:
System::Threading::Tasks::Task ^ FromAsync(IAsyncResult ^ asyncResult, Action<IAsyncResult ^> ^ endMethod);
public System.Threading.Tasks.Task FromAsync (IAsyncResult asyncResult, Action<IAsyncResult> endMethod);
member this.FromAsync : IAsyncResult * Action<IAsyncResult> -> System.Threading.Tasks.Task
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Action(Of IAsyncResult)) As Task
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Action<IAsyncResult>
動作委派,會處理已完成的 asyncResult
。
傳回
表示非同步作業的 Task。
例外狀況
備註
提示
FromAsync採用 asyncResult
參數的多載不像採用 beginMethod
參數的多載一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
System::Threading::Tasks::Task ^ FromAsync(Func<AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, System::Object ^ state);
public System.Threading.Tasks.Task FromAsync (Func<AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, object state);
public System.Threading.Tasks.Task FromAsync (Func<AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, object? state);
member this.FromAsync : Func<AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * obj -> System.Threading.Tasks.Task
Public Function FromAsync (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), state As Object) As Task
參數
- beginMethod
- Func<AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 由 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions)
建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。
public:
System::Threading::Tasks::Task ^ FromAsync(IAsyncResult ^ asyncResult, Action<IAsyncResult ^> ^ endMethod, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync (IAsyncResult asyncResult, Action<IAsyncResult> endMethod, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : IAsyncResult * Action<IAsyncResult> * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Action(Of IAsyncResult), creationOptions As TaskCreationOptions) As Task
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Action<IAsyncResult>
動作委派,會處理已完成的 asyncResult
。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
傳回
表示非同步作業的 Task。
例外狀況
paramref name="creationOptions" /> 指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
提示
FromAsync採用 asyncResult
參數的多載不像採用 beginMethod
參數的多載一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
System::Threading::Tasks::Task ^ FromAsync(Func<AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync (Func<AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync (Func<AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, object? state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task
Public Function FromAsync (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), state As Object, creationOptions As TaskCreationOptions) As Task
參數
- beginMethod
- Func<AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
傳回
建立的 Task,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 由 beginMethod
擲回的任何例外狀況。 值 TaskCreationOptionsPreferFairness 、 LongRunning 和 AttachedToParent 全都是互斥的。 在 FromAsync 方法中,或 LongRunning
AttachedToParent
本身會導致 ArgumentOutOfRangeException 擲回 。
另請參閱
適用於
FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions, TaskScheduler)
建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。
public:
System::Threading::Tasks::Task ^ FromAsync(IAsyncResult ^ asyncResult, Action<IAsyncResult ^> ^ endMethod, System::Threading::Tasks::TaskCreationOptions creationOptions, System::Threading::Tasks::TaskScheduler ^ scheduler);
public System.Threading.Tasks.Task FromAsync (IAsyncResult asyncResult, Action<IAsyncResult> endMethod, System.Threading.Tasks.TaskCreationOptions creationOptions, System.Threading.Tasks.TaskScheduler scheduler);
member this.FromAsync : IAsyncResult * Action<IAsyncResult> * System.Threading.Tasks.TaskCreationOptions * System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.Task
Public Function FromAsync (asyncResult As IAsyncResult, endMethod As Action(Of IAsyncResult), creationOptions As TaskCreationOptions, scheduler As TaskScheduler) As Task
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Action<IAsyncResult>
動作委派,會處理已完成的 asyncResult
。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
- scheduler
- TaskScheduler
TaskScheduler,用來排程可執行結束方法的工作。
傳回
建立的 Task,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
提示
FromAsync採用 asyncResult
參數的多載與採用 beginMethod
參數的多載不一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync<TArg1,TArg2,TArg3,TResult>(Func<TArg1,TArg2,TArg3,AsyncCallback, Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TArg3, typename TResult>
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,TResult> (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);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TArg3,TResult> (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, TResult) (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
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第三個引數類型。
- TArg3
傳遞至 beginMethod
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- arg3
- TArg3
傳遞至 beginMethod
委派的第三個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2,TArg3,TResult>(Func<TArg1,TArg2,TArg3,AsyncCallback, Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TArg3, typename TResult>
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,TResult> (Func<TArg1,TArg2,TArg3,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TArg3,TResult> (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, TResult) (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
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第三個引數類型。
- TArg3
傳遞至 beginMethod
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- arg3
- TArg3
傳遞至 beginMethod
委派的第三個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback, Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TArg3>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, TArg2, TArg3, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object? state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, 'TArg2, 'TArg3, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * 'TArg2 * 'TArg3 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1, TArg2, TArg3) (beginMethod As Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, arg2 As TArg2, arg3 As TArg3, state As Object, creationOptions As TaskCreationOptions) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第三個引數類型。
- TArg3
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- arg3
- TArg3
傳遞至 beginMethod
委派的第三個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
傳回
建立的 Task,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, TArg3, Object)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TArg3>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, TArg2, TArg3, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, System::Object ^ state);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object state);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2,TArg3> (Func<TArg1,TArg2,TArg3,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, object? state);
member this.FromAsync : Func<'TArg1, 'TArg2, 'TArg3, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * 'TArg2 * 'TArg3 * obj -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1, TArg2, TArg3) (beginMethod As Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, arg2 As TArg2, arg3 As TArg3, state As Object) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第三個引數類型。
- TArg3
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- arg3
- TArg3
傳遞至 beginMethod
委派的第三個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2,TResult>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TResult>
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,TResult> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, object state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TResult> (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, TResult) (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
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2,TResult>(Func<TArg1,TArg2,AsyncCallback, Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object, TaskCreationOptions)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2, typename TResult>
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,TResult> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, TArg2 arg2, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TArg2,TResult> (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, TResult) (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
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, Object)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, TArg2, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, TArg2 arg2, System::Object ^ state);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, object state);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, object? state);
member this.FromAsync : Func<'TArg1, 'TArg2, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * 'TArg2 * obj -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1, TArg2) (beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, arg2 As TArg2, state As Object) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, Object, TaskCreationOptions)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TArg2>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, TArg2, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, TArg2 arg2, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1,TArg2> (Func<TArg1,TArg2,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, TArg2 arg2, object? state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, 'TArg2, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * 'TArg2 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1, TArg2) (beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, arg2 As TArg2, state As Object, creationOptions As TaskCreationOptions) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第二個引數類型。
- TArg2
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- arg2
- TArg2
傳遞至 beginMethod
委派的第二個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
傳回
建立的 Task,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TResult>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TResult>
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,TResult> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, object state);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TResult> (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, TResult) (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
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1,TResult>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object, TaskCreationOptions)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1, typename TResult>
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,TResult> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, TArg1 arg1, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TArg1,TResult> (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, TResult) (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
委派的第一個引數類型。
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<TArg1,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, Object, TaskCreationOptions)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, System::Object ^ state, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task FromAsync<TArg1> (Func<TArg1,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, object? state, System.Threading.Tasks.TaskCreationOptions creationOptions);
member this.FromAsync : Func<'TArg1, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * obj * System.Threading.Tasks.TaskCreationOptions -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1) (beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, state As Object, creationOptions As TaskCreationOptions) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task 的行為。
傳回
建立的 Task,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, Object)
建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TArg1>
System::Threading::Tasks::Task ^ FromAsync(Func<TArg1, AsyncCallback ^, System::Object ^, IAsyncResult ^> ^ beginMethod, Action<IAsyncResult ^> ^ endMethod, TArg1 arg1, System::Object ^ state);
public System.Threading.Tasks.Task FromAsync<TArg1> (Func<TArg1,AsyncCallback,object,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, object state);
public System.Threading.Tasks.Task FromAsync<TArg1> (Func<TArg1,AsyncCallback,object?,IAsyncResult> beginMethod, Action<IAsyncResult> endMethod, TArg1 arg1, object? state);
member this.FromAsync : Func<'TArg1, AsyncCallback, obj, IAsyncResult> * Action<IAsyncResult> * 'TArg1 * obj -> System.Threading.Tasks.Task
Public Function FromAsync(Of TArg1) (beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), endMethod As Action(Of IAsyncResult), arg1 As TArg1, state As Object) As Task
類型參數
- TArg1
傳遞至 beginMethod
委派的第一個引數類型。
參數
- beginMethod
- Func<TArg1,AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Action<IAsyncResult>
結束非同步作業的委派。
- arg1
- TArg1
傳遞至 beginMethod
委派的第一個引數。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task,表示非同步作業。
例外狀況
備註
委派 beginMethod
會在執行所在的執行緒 FromAsync 上啟動。 這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions, TaskScheduler)
建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。
public:
generic <typename TResult>
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<TResult> (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(Of TResult) (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult), creationOptions As TaskCreationOptions, scheduler As TaskScheduler) As Task(Of TResult)
類型參數
- TResult
可透過工作取得的結果類型。
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Func<IAsyncResult,TResult>
函式委派,會處理已完成的 asyncResult
。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
- scheduler
- TaskScheduler
TaskScheduler,用來排程可執行結束方法的工作。
傳回
表示非同步作業的 Task<TResult>。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
提示
FromAsync採用 asyncResult
參數的多載與採用 beginMethod
參數的多載不一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions)
建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。
public:
generic <typename TResult>
System::Threading::Tasks::Task<TResult> ^ FromAsync(IAsyncResult ^ asyncResult, Func<IAsyncResult ^, TResult> ^ endMethod, System::Threading::Tasks::TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TResult> (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(Of TResult) (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult), creationOptions As TaskCreationOptions) As Task(Of TResult)
類型參數
- TResult
可透過工作取得的結果類型。
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Func<IAsyncResult,TResult>
函式委派,會處理已完成的 asyncResult
。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
傳回
表示非同步作業的 Task<TResult>。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
提示
FromAsync採用 asyncResult
參數的多載與採用 beginMethod
參數的多載不一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync<TResult>(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TResult>
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<TResult> (Func<AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, object state);
public System.Threading.Tasks.Task<TResult> FromAsync<TResult> (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(Of TResult) (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), state As Object) As Task(Of TResult)
類型參數
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
備註
這個方法會擲回 所 beginMethod
擲回的任何例外狀況。
另請參閱
適用於
FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>)
建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。
public:
generic <typename TResult>
System::Threading::Tasks::Task<TResult> ^ FromAsync(IAsyncResult ^ asyncResult, Func<IAsyncResult ^, TResult> ^ endMethod);
public System.Threading.Tasks.Task<TResult> FromAsync<TResult> (IAsyncResult asyncResult, Func<IAsyncResult,TResult> endMethod);
member this.FromAsync : IAsyncResult * Func<IAsyncResult, 'Result> -> System.Threading.Tasks.Task<'Result>
Public Function FromAsync(Of TResult) (asyncResult As IAsyncResult, endMethod As Func(Of IAsyncResult, TResult)) As Task(Of TResult)
類型參數
- TResult
可透過工作取得的結果類型。
參數
- asyncResult
- IAsyncResult
IAsyncResult,完成時會觸發 endMethod
處理作業。
- endMethod
- Func<IAsyncResult,TResult>
函式委派,會處理已完成的 asyncResult
。
傳回
表示非同步作業的 Task<TResult>。
例外狀況
備註
提示
FromAsync採用 asyncResult
參數的多載與採用 beginMethod
參數的多載不一樣有效率。 如果效能是問題,請使用提供模式的多 beginMethod
/endMethod
載。
另請參閱
適用於
FromAsync<TResult>(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object, TaskCreationOptions)
建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。
public:
generic <typename TResult>
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<TResult> (Func<AsyncCallback,object,IAsyncResult> beginMethod, Func<IAsyncResult,TResult> endMethod, object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
public System.Threading.Tasks.Task<TResult> FromAsync<TResult> (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(Of TResult) (beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), endMethod As Func(Of IAsyncResult, TResult), state As Object, creationOptions As TaskCreationOptions) As Task(Of TResult)
類型參數
- TResult
可透過工作取得的結果類型。
參數
- beginMethod
- Func<AsyncCallback,Object,IAsyncResult>
開始非同步作業的委派。
- endMethod
- Func<IAsyncResult,TResult>
結束非同步作業的委派。
- state
- Object
物件,包含 beginMethod
委派要使用的資料。
- creationOptions
- TaskCreationOptions
TaskCreationOptions 值,控制建立之 Task<TResult> 的行為。
傳回
建立的 Task<TResult>,表示非同步作業。
例外狀況
creationOptions
指定無效的 TaskCreationOptions 值。 如需詳細資訊,請參閱 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的<備註>
備註
這個方法會擲回 所 beginMethod
擲回的任何例外狀況。