public ContextScope(OperationContextPreservingSynchronizationContext newContext, OperationContext setAsCurrentForCallingThread = null)
        {
            if (newContext == null)
                throw new ArgumentNullException("newContext");

            _newContext = newContext;
            _oldContext = SynchronizationContext.Current;
            SynchronizationContext.SetSynchronizationContext(_newContext);

            if (setAsCurrentForCallingThread != null)
            {
                // Save it so we can restore it when we're disposed.
                _preexistingContext = OperationContext.Current;


                // Set-and-forget.
                new OperationContextScope(setAsCurrentForCallingThread);
            }
        }
        public ContextScope(OperationContextPreservingSynchronizationContext newContext, OperationContext setAsCurrentForCallingThread = null)
        {
            if (newContext == null)
            {
                throw new ArgumentNullException("newContext");
            }

            _newContext = newContext;
            _oldContext = SynchronizationContext.Current;
            SynchronizationContext.SetSynchronizationContext(_newContext);

            if (setAsCurrentForCallingThread != null)
            {
                // Save it so we can restore it when we're disposed.
                _preexistingContext = OperationContext.Current;


                // Set-and-forget.
                new OperationContextScope(setAsCurrentForCallingThread);
            }
        }