public override SynchronizationContext CreateCopy() { var copy = new DeadlockDetectionSynchronizationContext(BaseSynchronizationContext?.CreateCopy()); lock (_sync) { copy._isBlocking = _isBlocking; copy._blockingStacktrace = _blockingStacktrace; } return(copy); }
private Enable(DeadlockDetectionMode detectionMode) { _detectionMode = detectionMode; // Determine the current synchronization context and abort if we // only want to find actual deadlocks and there is no synchronization context var currentSynchronizationContext = SynchronizationContext.Current; if (currentSynchronizationContext == null && detectionMode == DeadlockDetectionMode.OnlyActualDeadlocks) { return; } // Install our deadlock detection synchronization context _deadlockDetectionSynchronizationContext = new DeadlockDetectionSynchronizationContext(currentSynchronizationContext); SynchronizationContext.SetSynchronizationContext(_deadlockDetectionSynchronizationContext); }