Hello,
I have a program that I run and in the middle I get this message:
Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\Documents and Settings\Lena G\My Documents\SchoolStuff\IR Information\Home Work\FianlProject\finalProject\finalProject\bin\Debug\finalProject.vshost.exe'. Additional Information: The CLR has been unable to transition from COM context 0x3407968 to COM context 0x3407ad8 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.
I understand that it has something to do with the fact that it runs for 60 seconds without stopping or something like that? How is it a problem? I also put [STAThread] before the main of my program because if I remove it then it shows me this message:
An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
Anyone know how I can solve this problem?
Thanks in advance,
Lena