AsyncTaskMethodBuilder<TResult> 结构
定义
表示异步方法的生成器,该生成器将返回任务并提供结果的参数。Represents a builder for asynchronous methods that returns a task and provides a parameter for the result.
generic <typename TResult>
public value class AsyncTaskMethodBuilder
public struct AsyncTaskMethodBuilder<TResult>
type AsyncTaskMethodBuilder<'Result> = struct
Public Structure AsyncTaskMethodBuilder(Of TResult)
类型参数
- TResult
用来完成任务的结果。The result to use to complete the task.
- 继承
注解
此类型及其成员旨在供编译器使用。This type and its members are intended for use by the compiler.
属性
| Task |
获取此生成器的任务。Gets the task for this builder. |
方法
| AwaitOnCompleted<TAwaiter,TStateMachine>(TAwaiter, TStateMachine) |
指定的 Awaiter 完成时,安排状态机以继续下一操作。Schedules the state machine to proceed to the next action when the specified awaiter completes. |
| AwaitUnsafeOnCompleted<TAwaiter,TStateMachine>(TAwaiter, TStateMachine) |
指定的 Awaiter 完成时,安排状态机以继续下一操作。Schedules the state machine to proceed to the next action when the specified awaiter completes. 可从部分受信任的代码调用此方法。This method can be called from partially trusted code. |
| Create() |
创建 AsyncTaskMethodBuilder<TResult> 类的实例。Creates an instance of the AsyncTaskMethodBuilder<TResult> class. |
| SetException(Exception) |
标记此任务为失败并将指定的异常绑定到此任务。Marks the task as failed and binds the specified exception to the task. |
| SetResult(TResult) |
将该任务标记为已成功完成。Marks the task as successfully completed. |
| SetStateMachine(IAsyncStateMachine) |
将生成器与指定的状态机相关联。Associates the builder with the specified state machine. |
| Start<TStateMachine>(TStateMachine) |
开始运行具有关联状态机的生成器。Begins running the builder with the associated state machine. |