/// <summary> /// Detach the context from the its task environment. /// </summary> /// <remarks> /// Must be done in the context's task environment. /// </remarks> public void DetachFromTaskEnv() { lock (this) { if (TaskEnv.CurrentOrNull != _ownerEnv) { _log.Warn("detaching context in env other than owning end"); } _ownerEnv.RemoveState(this); _ownerEnv = null; } }