System.Threading.Tasks.Task.FromResult(TWrapper)

Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(TWrapper) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

19 Source : InvokeHelpers.cs
with MIT License
from ipjohnson

public static Task<TWrapper> WrapResult<TWrapper, TResult>(TResult result) where TWrapper : IResultWrapper<TResult>, new()
        {
            return Task.FromResult(new TWrapper { Result = result });
        }

19 Source : InvokeHelpers.cs
with MIT License
from ipjohnson

public static Task<TWrapper> WrapResultTaskAsync<TWrapper, TResult>(Task<TResult> result) where TWrapper : IResultWrapper<TResult>, new()
        {
            if (result.IsCompletedSuccessfully)
            {
                return Task.FromResult(new TWrapper { Result = result.Result });
            }

            return CompleteTaskAsync(result);

            static async Task<TWrapper> CompleteTaskAsync(Task<TResult> r)
            {
                return new TWrapper { Result = await r };
            }
        }

19 Source : InvokeHelpers.cs
with MIT License
from ipjohnson

public static Task<TWrapper> WrapResultValueTaskAsync<TWrapper, TResult>(ValueTask<TResult> result) where TWrapper : IResultWrapper<TResult>, new()
        {
            if (result.IsCompletedSuccessfully)
            {
                return Task.FromResult(new TWrapper { Result = result.Result });
            }

            return CompleteTaskAsync(result);

            static async Task<TWrapper> CompleteTaskAsync(ValueTask<TResult> r)
            {
                return new TWrapper { Result = await r };
            }
        }