public static TResult Run <TResult>(Func <TResult> func)
        {
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            using (var context = new STAContext())
            {
                var task = context.StartTask(func);
                context.Execute();

                return(task.GetAwaiter().GetResult());
            }
        }
        public static void Run(Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            using (var context = new STAContext())
            {
                var task = context.StartTask(action);
                context.Execute();

                task.GetAwaiter().GetResult();
            }
        }
        public static void Run(Func <Task> func)
        {
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            using (var context = new STAContext())
            {
                context.OperationStarted();
                var task = context.StartTask(func).Unwrap().ContinueWith(t =>
                {
                    // ReSharper disable once AccessToDisposedClosure
                    context.OperationCompleted();
                    t.GetAwaiter().GetResult();
                }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, context._taskScheduler);

                context.Execute();
                task.GetAwaiter().GetResult();
            }
        }