dangerousThreadingAPI MDA

The dangerousThreadingAPI managed debugging assistant (MDA) is activated when the Thread.Suspend method is called on a thread other than the current thread.


An application is unresponsive or hangs indefinitely. System or application data might be left in an unpredictable state temporarily or even after an application has been shut down. Some operations are not completing as expected.

Symptoms can vary widely due to the randomness inherent to the problem.


A thread is asynchronously suspended by another thread using the Suspend method. There is no way to determine when it is safe to suspend another thread which might be in the middle of an operation. Suspending the thread can result in the corruption of data or the breaking of invariants. Should a thread be placed into a suspended state and never resumed using the Resume method, the application can hang indefinitely and possibly damage application data. These methods have been marked as obsolete.

If synchronization primitives are held by the target thread, they remain held during suspension. This can lead to deadlocks should another thread, for example the thread performing the Suspend, attempt to acquire a lock on the primitive. In this situation, the problem manifests itself as a deadlock.


Avoid designs that require the use of Suspend and Resume. For cooperation between threads, use synchronization primitives such as Monitor, ReaderWriterLock, Mutex, or the C# lockstatement. If you must use these methods, reduce the window of time and minimize the amount of code that executes while the thread is in a suspended state.

Effect on the Runtime

This MDA has no effect on the CLR. It only reports data about dangerous threading operations.


The MDA identifies the dangerous threading method that caused it to be activated.


    <dangerousThreadingAPI />


The following code example demonstrates a call to the Suspend method that causes the activation of the dangerousThreadingAPI.

using System.Threading;
void FireMda()
    Thread t = new Thread(delegate() { Thread.Sleep(1000); });
    // The following line activates the MDA.

See Also


Diagnosing Errors with Managed Debugging Assistants



lock Statement (C# Reference)