Exemplo n.º 1
0
        public static Task <T> FromResult <T>(T result)
        {
#if NET451
            return(TaskExCache <T> .GetCompleted(result));
#else
            return(Task.FromResult <T>(result));
#endif
        }
Exemplo n.º 2
0
        public static Task <T> FromCanceled <T>(CancellationToken cancellationToken)
        {
#if NET451
            return(TaskExCache <T> .GetCancelled(cancellationToken));
#else
            return(Task.FromCanceled <T>(cancellationToken));
#endif
        }
Exemplo n.º 3
0
        public static Task <T> FromException <T>(Exception exception)
        {
#if NET451
            return(TaskExCache <T> .GetFromException(exception));
#else
            return(Task.FromException <T>(exception));
#endif
        }
Exemplo n.º 4
0
        public static Task <T> FromCanceled <T>(CancellationToken cancellationToken)
        {
#if NET451
            return(TaskExCache <T> .GetCancelled(cancellationToken));
#else
            return(Task.FromCanceled <T>(cancellationToken.IsCancellationRequested ? cancellationToken : new CancellationToken(true)));
#endif
        }