Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (48 sloc) 1.275 kB
using System;
using PortableTPL.Cancellation;
namespace PortableTPL.Task
{
public partial class Task<T> : Task
{
T _result;
public T Result
{
get
{
ThrowAggregateExceptionIfPresent();
return _result;
}
}
public Task(Func<T> func)
{
ActionDelegate = func;
}
public Task(Func<object, T> func, object state)
{
ActionDelegate = func;
AsyncState = state;
}
public Task(Func<T> func, CancellationToken token)
{
ActionDelegate = func;
token.Register(OnCancellation);
}
public Task(Func<object, T> func, object state, CancellationToken token)
{
ActionDelegate = func;
AsyncState = state;
token.Register(OnCancellation);
}
protected override void ExecuteDelegate()
{
if (ActionDelegate.Method.GetParameters().Length > 0)
{
_result = (T)ActionDelegate.DynamicInvoke(AsyncState);
}
else
{
_result = (T)ActionDelegate.DynamicInvoke();
}
}
}
}
Jump to Line
Something went wrong with that request. Please try again.