예제 #1
0
            public TaskCompletionSourceInfo(Type resultType)
            {
                ResultType = resultType;
                Type tcsType = typeof(TaskCompletionSource <>);

                GenericType           = tcsType.MakeGenericType(new Type[] { resultType });
                TaskProperty          = GenericType.GetTypeInfo().GetDeclaredProperty("Task");
                TrySetResultMethod    = GenericType.GetTypeInfo().GetDeclaredMethod("TrySetResult");
                TrySetExceptionMethod = GenericType.GetRuntimeMethod("TrySetException", new Type[] { typeof(Exception) });
                TrySetCanceledMethod  = GenericType.GetRuntimeMethod("TrySetCanceled", Array.Empty <Type>());
            }