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.

Task<TResult>的使用的更多相关文章

  1. 第八节:Task的各类Task<TResult>返回值以及通用线程的异常处理方案。

    一. Task的各种返回值-Task<TResult> PS: 在前面章节,我们介绍了Task类开启线程.线程等待.线程延续的方式,但我们并没有关注这些方式的返回值,其实他们都是有返回值的 ...

  2. C#异步编程のTask模型返回值Task<TResult>应用

    文中所有Task<TResult>的返回值都是直接用task.result获取,这样如果后台任务没有执行完毕的话,主线程会等待其执行完毕,这样的话就和同步一样了(看上去一样,但其实awai ...

  3. Task作为返回值以及Task<TResult>作为返回值

    async await return Task https://stackoverflow.com/questions/25191512/async-await-return-task Can som ...

  4. 【C# Task】 ValueTask/Task<TResult>

    概要 1.如果异步方法的使用者使用 Task.WhenAll 或 Task.WhenAny,则在异步方法中使用 ValueTask<T> 作为返回类型可能会产生高昂的成本.这是因为您需要使 ...

  5. Task<TResult> 类

    https://msdn.microsoft.com/zh-cn/library/dd321424.aspx

  6. .Net多线程编程—任务Task

    1 System.Threading.Tasks.Task简介 一个Task表示一个异步操作,Task的创建和执行是独立的. 只读属性: 返回值 名称 说明 object AsyncState 表示在 ...

  7. Task异步编程

    Task异步编程中,可以实现在等待耗时任务的同时,执行不依赖于该耗时任务结果的其他同步任务,提高效率. 1.Task异步编程方法签名及返回值: a) 签名有async 修饰符 b) 方法名以 Asyn ...

  8. 细说.NET中的多线程 (三 使用Task)

    上一节我们介绍了线程池相关的概念以及用法.我们可以发现ThreadPool. QueueUserWorkItem是一种起了线程之后就不管了的做法.但是实际应用过程,我们往往会有更多的需求,比如如果更简 ...

  9. 实践基于Task的异步模式

    Await 返回该系列目录<基于Task的异步模式--全面介绍> 在API级别,实现没有阻塞的等待的方法是提供callback(回调函数).对于Tasks来说,这是通过像ContinueW ...

随机推荐

  1. ralink网卡驱动的下载地址集合

    linuxMT7612U11/7/2014v3.0.0.1http://cdn-cw.mediatek.com/Downloads/linux/MT7612U_DPO_LinuxSTA_3.0.0.1 ...

  2. Spring之AOP面向切片

       一.理论基础: AOP(Aspectoriented programming)面向切片/服务的编程,在Spring中使用最多的是对事物的处理.而AOP这种思想在程序中很多地方可以使用的,比如说, ...

  3. android 应用架构随笔一(架构搭建)

    1.拷贝积累utils以及PagerTab类 2.定义BaseApplication类 3.定义BaseActivity类 4.改写MainActivity 5.定义布局文件 6.定义BaseFrag ...

  4. scala的apply方法

    package com.test.scala.test /** * apply 方法 */ object ApplyTest { def main(args: Array[String]): Unit ...

  5. Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义【转】

    转自:http://www.cnblogs.com/kaituorensheng/p/4002697.html 1 2 3 4 5 6 7 8 $# 是传给脚本的参数个数 $0 是脚本本身的名字 $1 ...

  6. webapi获取请求地址的IP

    References required: HttpContextWrapper - System.Web.dll RemoteEndpointMessageProperty - System.Serv ...

  7. [转]学习 WCF (6)--学习调用WCF服务的各种方法

    转自:http://www.cnblogs.com/gaoweipeng/archive/2009/07/26/1528263.html 作者这篇博文写得很全面. 根据不同的情况,我们可以用不同的方法 ...

  8. Temporary TempDB Tables [AX 2012]

    Temporary TempDB Tables [AX 2012] 1 out of 4 rated this helpful - Rate this topic Updated: November ...

  9. hdwiki 软件包结构

    HDWiki软件包结构转载自http://www.chinabaike.com/z/shenghuo/pc/2011/0414/814308.html           根目录下的PHP文件     ...

  10. 【转】Cookie和Session的区别详解

    转载地址:http://www.phperzone.cn/portal.php?aid=541&mod=view 一.cookie机制和session机制的区别 具体来说cookie机制采用的 ...