Task<TResult>的使用

https://msdn.microsoft.com/en-us/library/dd321424(v=vs.110).aspx

Represents an asynchronous operation that can return a value.

Type Parameters
TResult

The type of the result produced by this Task<TResult>.

 

 

Task<TResult>.Result 属性

Gets the result value of this Task<TResult>.

public TResult Result { get; }

The result value of this Task<TResult>, which is the same type as the task's type parameter.

 

Accessing the property's get accessor blocks the calling thread until the asynchronous operation is complete; it is equivalent to calling the Wait method.

尝试获取Result会阻塞调用线程,直到异步操作完成。这等价于调用Wait方法。

Once the result of an operation is available, it is stored and is returned immediately on subsequent calls to the Result property.

Note that, if an exception occurred during the operation of the task, or if the task has been cancelled, the Result property does not return a value.

Instead, attempting to access the property value throws an AggregateException exception.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值