Exemplo n.º 1
0
 private static CompletedAsyncInfo <T, TProgress> CreateCache <T>(T result)
 {
     if (Equals(result, default(T)))
     {
         return(CompletedAsyncInfo <T, TProgress> .Instanse);
     }
     return(CompletedAsyncInfo <T, TProgress> .Create(result));
 }
Exemplo n.º 2
0
        private static CompletedAsyncInfo <T, TProgress>[] CreateRange <T>()
        {
            var resultType = typeof(T);
            var r          = new CompletedAsyncInfo <T, TProgress> [CACHE_END - CACHE_START];

            for (var i = 0; i < r.Length; i++)
            {
                r[i] = CreateCache((T)Convert.ChangeType(CACHE_START + i, resultType));
            }
            return(r);
        }
 /// <summary>
 /// Create a complated <see cref="IAsyncOperationWithProgress{TResult, TProgress}"/>.
 /// </summary>
 /// <param name="results">Results of the operation.</param>
 /// <returns>A complated <see cref="IAsyncOperationWithProgress{TResult, TProgress}"/>.</returns>
 public static IAsyncOperationWithProgress <T, TProgress> CreateCompleted(T results)
 => AsyncOperationCache <TProgress> .TryGetCacehd(results) ?? CompletedAsyncInfo <T, TProgress> .Create(results);
Exemplo n.º 4
0
 /// <summary>
 /// Create a complated <see cref="IAsyncOperation{TResult}"/>.
 /// </summary>
 /// <param name="results">Results of the operation.</param>
 /// <returns>A complated <see cref="IAsyncOperation{TResult}"/>.</returns>
 public static IAsyncOperation <T> CreateCompleted(T results)
 => AsyncOperationCache <VoidProgress> .TryGetCacehd(results) ?? CompletedAsyncInfo <T, VoidProgress> .Create(results);