zunebuggy65
Active member
- Joined
- Oct 12, 2023
- Messages
- 42
- Programming Experience
- 3-5
So my Windows Desktop application is writing a large amount of data to a binary file and has a ProgressBar that increments until it is written. There is one Sub that writes a lot of data and I get this error below, about halfway through:
The exception states: "Managed Debugging Assistant 'ContextSwitchDeadlock' : 'The CLR has been unable to transition from COM context 0xd06388 to COM context 0xd062d0 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 am able to click Continue and it finishes writing the file just fine. So I guess by reading this Exception, it wants be to display more on the screen while it is completing. I already have the ProgressBar updating AND I also have a Label that I update the text on constantly during the process.
I have the Performance panel turned on and I can see, as I would expect, it is fairly busy when the file is writing, but only when it's writing.
I do not want to add an On Error Resume Next event to my application.
I have another Sub where I write a file of the same length or longer, have the ProgressBar and Label update, but I do not get this error.
Is there a way to avoid this error or the best way to troubleshoot it further so I can get rid of it?
Thank you
The exception states: "Managed Debugging Assistant 'ContextSwitchDeadlock' : 'The CLR has been unable to transition from COM context 0xd06388 to COM context 0xd062d0 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 am able to click Continue and it finishes writing the file just fine. So I guess by reading this Exception, it wants be to display more on the screen while it is completing. I already have the ProgressBar updating AND I also have a Label that I update the text on constantly during the process.
I have the Performance panel turned on and I can see, as I would expect, it is fairly busy when the file is writing, but only when it's writing.
I do not want to add an On Error Resume Next event to my application.
I have another Sub where I write a file of the same length or longer, have the ProgressBar and Label update, but I do not get this error.
Is there a way to avoid this error or the best way to troubleshoot it further so I can get rid of it?
Thank you