// If ContextCopy or Identity will be used, the return value should be locked until FinishPostingAsyncOp() is called
// or the operation has been aborted (e.g. by BeginXxx throwing). Otherwise, this can be called with false to prevent the lock
// object from being created.
internal object StartPostingAsyncOp(bool lockCapture)
{
if (InternalPeekCompleted)
{
NetEventSource.Fail(this, "Called on completed result.");
}
DebugProtectState(true);
_lock = lockCapture ? new object() : null;
_flags |= StateFlags.PostBlockStarted;
return(_lock);
}