public virtual void Revert(object previousState)
{
var switcher = previousState as HostExecutionContextSwitcher;
if (switcher == null)
{
throw new InvalidOperationException(
SR.HostExecutionContextManager_InvalidOperation_CannotOverrideSetWithoutRevert);
}
if (t_currentContext != switcher._currentContext || switcher._asyncLocal == null || !switcher._asyncLocal.Value)
{
throw new InvalidOperationException(
SR.HostExecutionContextManager_InvalidOperation_CannotUseSwitcherOtherThread);
}
switcher._asyncLocal = null; // cannot be reused
// Revert always reverts to a null host execution context when not hosted
t_currentContext = null;
}