/// <summary> /// Enables deadlock detection. /// </summary> public static void Enable() { // Switch out the default TaskScheduler. We must use reflection because it is private. FieldInfo defaultTaskScheduler = typeof(TaskScheduler).GetField("s_defaultTaskScheduler", BindingFlags.NonPublic | BindingFlags.Static); DeadlockDetectionTaskScheduler newTaskScheduler = new DeadlockDetectionTaskScheduler(); defaultTaskScheduler.SetValue(null, newTaskScheduler); s_threadDueTimes = new ConcurrentDictionary<Thread, ThreadInfo>(); s_deadlockWatchdog = new Timer(CheckForDeadlocks, null, _watchdogIntervalMs, _watchdogIntervalMs); s_isEnabled = true; }
/// <summary> /// Enables deadlock detection. /// </summary> public static void Enable() { // Switch out the default TaskScheduler. We must use reflection because it is private. FieldInfo defaultTaskScheduler = typeof(TaskScheduler).GetField("s_defaultTaskScheduler", BindingFlags.NonPublic | BindingFlags.Static); DeadlockDetectionTaskScheduler newTaskScheduler = new DeadlockDetectionTaskScheduler(); defaultTaskScheduler.SetValue(null, newTaskScheduler); s_threadDueTimes = new ConcurrentDictionary <Thread, ThreadInfo>(); s_deadlockWatchdog = new Timer(CheckForDeadlocks, null, _watchdogIntervalMs, _watchdogIntervalMs); s_isEnabled = true; }