TaskFactory.FromAsync 方法

定义

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

重载

FromAsync(IAsyncResult, Action<IAsyncResult>)

创建一个 Task,它在指定的 IAsyncResult 完成时执行一个结束方法操作。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions)

创建一个 Task,它在指定的 IAsyncResult 完成时执行一个结束方法操作。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions, TaskScheduler)

创建一个 Task,它在指定的 IAsyncResult 完成时执行一个结束方法操作。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

创建一个 Task<TResult>,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

创建一个 Task<TResult>,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

创建一个 Task<TResult>,表示符合异步编程模型模式的成对的开始和结束方法。

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

表示异步操作的 Task

例外

asyncResult 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

提示

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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 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

表示异步操作的 Task

例外

asyncResult 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

creationOptions 指定了无效的 TaskCreationOptions 值。

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the beginMethod. 这些TaskCreationOptionsPreferFairnessLongRunning,并且AttachedToParent都是相互排斥的。 在 FromAsync 方法中, LongRunningAttachedToParent 本身将导致 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

创建的表示异步操作的 Task

例外

asyncResult 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

  • 或 - scheduler 上声明的默认值为 null

注解

提示

采用asyncResult参数的FromAsync重载不如采用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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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

创建的表示异步操作的 Task

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

委托 beginMethod 在正在运行的线程 FromAsync 上启动。 This method throws any exceptions thrown by the 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>

表示异步操作的 Task<TResult>

例外

asyncResult 上声明的默认值为 null

  • 或 -

endMethod 上声明的默认值为 null

  • 或 - scheduler 上声明的默认值为 null

creationOptions 指定了无效的 TaskCreationOptions 值。 有关更多信息,请参见 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的备注

注解

提示

采用asyncResult参数的FromAsync重载不如采用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>

表示异步操作的 Task<TResult>

例外

asyncResult 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

提示

采用asyncResult参数的FromAsync重载不如采用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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

This method throws any exceptions thrown by the 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>

表示异步操作的 Task<TResult>

例外

asyncResult 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

提示

采用asyncResult参数的FromAsync重载不如采用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>

创建的表示异步操作的 Task<TResult>

例外

beginMethod 上声明的默认值为 null

  • 或 - endMethod 上声明的默认值为 null

注解

This method throws any exceptions thrown by the beginMethod.

另请参阅

适用于