public void Undo()
{
if (this.thread != null)
{
if (this.thread != Thread.CurrentThread)
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotUseSwitcherOtherThread"));
}
if (this.currEC != Thread.CurrentThread.GetExecutionContextNoCreate())
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SwitcherCtxMismatch"));
}
this.scsw.Undo();
try
{
HostExecutionContextSwitcher.Undo(this.hecsw);
}
finally
{
this.sysw.Undo();
}
Thread.CurrentThread.SetExecutionContext(this.prevEC);
this.thread = null;
}
}