joe_pool_is
Well-known member
I got this message today while debugging through a very small program using Visual Studio 2005 Express with my C# program:
It froze on the statement
Why? Did I do something, or was this something caused by some other Microsoft thing running in the background?
This has only happened once; I have not been able to reproduce it.
ContextSwitchDeadlock was detected Message:
The CLR has been unable to transition from COM context 0x1b11b8 to COM context 0x1b1328 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Is this something that I could have caused in my simple application? (All it does is fools around with registry settings, learning how to use different tools like the commonDialog in C# 2005, etc.) I was stepping over this piece of code when the debugger froze.
The CLR has been unable to transition from COM context 0x1b11b8 to COM context 0x1b1328 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Code:
// String folder
// = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
private void RegistryWork(bool bIn) {
String program = System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath);
try { // HKEY_CURRENT_USER\Software\poojo.com\program
Microsoft.Win32.RegistryKey rkSoftware;
rkSoftware = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software");
Microsoft.Win32.RegistryKey rkCompany = rkSoftware.CreateSubKey("poojo.com");
Microsoft.Win32.RegistryKey rkProgram = rkCompany.CreateSubKey(program);
if (bIn == true) {
rkProgram.GetValue("Folder", folder);
} else {
rkProgram.SetValue("Folder", folder, Microsoft.Win32.RegistryValueKind.String);
}
} catch (Exception ex) {
MessageBox.Show("Unable to use registry.\n" + ex.Message, "Registry", MessageBoxButtons.OK);
}
}
Code:
if (bIn == true)
This has only happened once; I have not been able to reproduce it.