TaskFactory<TResult>.FromAsync 方法

定义

创建一个任务实例。

重载

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>)

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

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

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

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

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

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

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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

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

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

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

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

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

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

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

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

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

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

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

FromAsync(IAsyncResult, Func<IAsyncResult,TResult>)

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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 的处理。

endMethod
Func<IAsyncResult,TResult>

用于处理完成的 asyncResult 的函数委托。

返回

表示异步操作的 Task<TResult>

例外

asyncResult 参数为 null

- 或 -

endMethod 参数为 null

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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>

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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 的处理。

endMethod
Func<IAsyncResult,TResult>

用于处理完成的 asyncResult 的函数委托。

creationOptions
TaskCreationOptions

控制所创建的任务的行为的枚举值之一。

返回

表示异步操作的任务。

例外

asyncResult 参数为 null

- 或 -

endMethod 参数为 null

creationOptions 参数指定的值无效。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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>

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

creationOptions
TaskCreationOptions

控制所创建的任务的行为的枚举值之一。

返回

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

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

creationOptions 参数指定的值无效。

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

创建一个任务,它在指定的 IAsyncResult 完成时执行一个结束方法函数。

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 的处理。

endMethod
Func<IAsyncResult,TResult>

用于处理完成的 asyncResult 的函数委托。

creationOptions
TaskCreationOptions

控制所创建的任务的行为的枚举值之一。

scheduler
TaskScheduler

用于计划将执行结束方法的任务计划程序。

返回

创建的表示异步操作的任务。

例外

asyncResult 参数为 null

- 或 -

endMethod 参数为 null

- 或 -

scheduler 参数为 null

creationOptions 参数指定的值无效。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第二个自变量的类型。

TArg2

传递给 beginMethod 委托的第三个参数的类型。

TArg3

传递给 beginMethod 委托的第一个自变量的类型。

参数

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

一个对象,用于控制所创建的任务的行为。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

creationOptions 参数指定的值无效。

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第二个自变量的类型。

TArg2

传递给 beginMethod 委托的第三个参数的类型。

TArg3

传递给 beginMethod 委托的第一个自变量的类型。

参数

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

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

arg1
TArg1

传递给 beginMethod 委托的第一个参数。

arg2
TArg2

传递给 beginMethod 委托的第二个自变量。

arg3
TArg3

传递给 beginMethod 委托的第三个参数。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod在等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第二个自变量的类型。

TArg2

传递给 beginMethod 委托的第一个自变量的类型。

参数

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

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

arg1
TArg1

传递给 beginMethod 委托的第一个参数。

arg2
TArg2

传递给 beginMethod 委托的第二个自变量。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

creationOptions
TaskCreationOptions

一个对象,用于控制所创建的 Task<TResult> 的行为。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

creationOptions 参数指定的值无效。

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod在等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第二个自变量的类型。

TArg2

传递给 beginMethod 委托的第一个自变量的类型。

参数

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

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

arg1
TArg1

传递给 beginMethod 委托的第一个参数。

arg2
TArg2

传递给 beginMethod 委托的第二个自变量。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod在等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第一个自变量的类型。

参数

beginMethod
Func<TArg1,AsyncCallback,Object,IAsyncResult>

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

arg1
TArg1

传递给 beginMethod 委托的第一个自变量。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod在等待返回的任务时,会引发 异常。

另请参阅

适用于

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

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

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);
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 委托的第一个自变量的类型。

参数

beginMethod
Func<TArg1,AsyncCallback,Object,IAsyncResult>

用于启动异步操作的委托。

endMethod
Func<IAsyncResult,TResult>

用于结束异步操作的委托。

arg1
TArg1

传递给 beginMethod 委托的第一个自变量。

state
Object

一个包含由 beginMethod 委托使用的数据的对象。

creationOptions
TaskCreationOptions

控制所创建的任务的行为的枚举值之一。

返回

创建的表示异步操作的任务。

例外

beginMethod 参数为 null

- 或 -

endMethod 参数为 null

creationOptions 参数指定的值无效。

注解

此方法引发 由 beginMethod引发的任何异常。 endmethod在等待返回的任务时,会引发 异常。

另请参阅

适用于