标签:os io ar art new .net res ad
using System; using System.Threading; using System.Threading.Tasks; namespace Microsoft.AspNet.Identity { internal static class AsyncHelper { private static readonly TaskFactory _myTaskFactory = new TaskFactory(CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default); public static TResult RunSync<TResult>(Func<Task<TResult>> func) { return _myTaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult(); } public static void RunSync(Func<Task> func) { _myTaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult(); } } }
在同步中调用异步方法[.net 4.5],布布扣,bubuko.com
标签:os io ar art new .net res ad
原文地址:http://www.cnblogs.com/zbw911/p/3907672.html