Created On:  24 November 2010


I see a RaceOnRCWCleanup MDA when debugging COBOL WPF applications.


If you compile a COBOL WPF application for either x64 or AnyCPU on a 64-bit machine, when debugging it you might see Visual Studio display a Managed Debugging Assistant (MDA) warning you of the condition RaceOnRCWCleanup when the application exits. The default WPF template avoids this condition by including an OnExit handler which finishes with a STOP RUN statement.

The OnExit handler is included in the main application class for the project (App.xaml.cbl by default). However, if you include your own handler for the Closed event on the main Window of the application, the OnExit handler is not executed and the MDA will reappear during debugging. Put the Stop Run as the last statement executed in your application code (so at the end of your Closed handler) to make it go away again.

MDAs are provided by Visual Studio to warn you of potential problems in an application that do not necessarily throw an exception or cause another error. For more information about this MDA, see the following article on the Microsoft MSDN site: