解决MySql布尔型新旧版本兼容问题,采用枚举来表示布尔型的数据表。由正向工程赋值
大石头 authored at 2018-05-15 21:21:05
2.11 KiB
X
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

//[assembly: TypeForwardedTo(typeof(AggregateException))]
//[assembly: TypeForwardedTo(typeof(OperationCanceledException))]
//[assembly: TypeForwardedTo(typeof(CancellationToken))]
//[assembly: TypeForwardedTo(typeof(CancellationTokenRegistration))]
//[assembly: TypeForwardedTo(typeof(CancellationTokenSource))]
//[assembly: TypeForwardedTo(typeof(Task))]
//[assembly: TypeForwardedTo(typeof(Task<>))]
//[assembly: TypeForwardedTo(typeof(TaskCanceledException))]
//[assembly: TypeForwardedTo(typeof(TaskCompletionSource<>))]
//[assembly: TypeForwardedTo(typeof(TaskContinuationOptions))]
//[assembly: TypeForwardedTo(typeof(TaskCreationOptions))]
//[assembly: TypeForwardedTo(typeof(TaskExtensions))]
//[assembly: TypeForwardedTo(typeof(TaskFactory))]
//[assembly: TypeForwardedTo(typeof(TaskFactory<>))]
//[assembly: TypeForwardedTo(typeof(TaskScheduler))]
//[assembly: TypeForwardedTo(typeof(TaskSchedulerException))]
//[assembly: TypeForwardedTo(typeof(TaskStatus))]
//[assembly: TypeForwardedTo(typeof(UnobservedTaskExceptionEventArgs))]

namespace System.Runtime.CompilerServices
{
    internal static class AsyncServices
    {
        internal static void ThrowAsync(Exception exception, SynchronizationContext targetContext)
        {
            if (targetContext != null)
            {
                try
                {
                    targetContext.Post(state => throw PrepareExceptionForRethrow((Exception)state), exception);
                    return;
                }
                catch (Exception ex)
                {
                    exception = new AggregateException(new Exception[]
                    {
                        exception,
                        ex
                    });
                }
            }
            ThreadPool.QueueUserWorkItem(state => throw PrepareExceptionForRethrow((Exception)state), exception);
            //throw new Exception("error", exception);
        }

        internal static Exception PrepareExceptionForRethrow(Exception exc) => new AggregateException(exc);
    }
}