Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
Task(TResult) Class
 Result Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Result Property

Gets the result value of this Task<(Of <(TResult>)>).

Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic
Public Property Result As TResult
    Get
    Friend Set
C#
public TResult Result { get; internal set; }
Visual C++
public:
property TResult Result {
    TResult get ();
    internal: void set (TResult value);
}
F#
member Result : 'TResult with get, internal set

Property Value

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

The get accessor for this property ensures that the asynchronous operation is complete before returning. Once the result of the computation is available, it is stored and will be returned immediately on later calls to Result.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
This throws exceptions.      .Paul the Dev   |   Edit   |   Show History
If the task faulted, accessing the Result property will throw an AggregateException.
Tags What's this?: Add a tag
Flag as ContentBug
If result is not ready,      Exception duck ... Thomas Lee   |   Edit   |   Show History

Can we check if result is ready and if not, just omit the value ?

something like

string s="nope";

if(task1.IsReady())

s = task1.Result;


and s will be "nope" or "duck" (as those are the only results I'm interested in)


Esther Fan, MSFT: Thank you for your feedback. To get a quicker response to questions like this, please try the following forums:
  

MSDN: http://forums.microsoft.com/msdn

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker