public void EndDraw() { var newFrame = Interlocked.Exchange(ref _FrameBeingPrepared, null); PrepareNextFrame(newFrame); if (_Running) { if (DoThreadedIssue) { lock (UseResourceLock) if (!_SyncBeginDraw()) { Interlocked.Exchange(ref _DrawIsActive, 0); return; } _DrawThread.RequestWork(); } else { ThreadedDraw(_DrawThread); } if (_DeviceLost) { WaitForActiveDraw(); _DeviceLost = IsDeviceLost; } } else { Interlocked.Exchange(ref _DrawIsActive, 0); } }