public T GetResult()
        {
            ConditionHelper.Assert(IsCompleted);

            if (exception != null)
            {
                ExceptionDispatchInfo.Capture(exception).Throw();
            }

            return(result);
        }
        public void Complete(T result, Exception e)
        {
            ConditionHelper.Assert(!IsCompleted);

            IsCompleted = true;
            exception   = e;
            this.result = result;

            if (continueWith != null)
            {
                UnitySchedulerProvider.RunOnUnityScheduler(continueWith);
            }
        }
        void INotifyCompletion.OnCompleted(Action continuation)
        {
            ConditionHelper.Assert(continueWith == null || !IsCompleted);

            continueWith = continuation;
        }