Context Deadlock Switch

When I started my application after a while, this happened. what is an exception and how can I handle this exception

The CLR could not move from the COM context 0x647f10 to the COM context 0x648080 for 60 seconds. The thread that owns the destination context / apartment is most likely either not waiting for pumping, or processing very long work without pumping Windows Messages. This situation usually negatively affects performance and may even cause the application to become inactive or use memory storage continuously over time. To avoid this problem, all threads with a single thread (STA) should use pumping primitives (such as CoWaitForMultipleHandles) and routine pumping messages during long operations.

+6
source share
2 answers

This usually happens if you have something blocking the user interface thread and using COM components.

The best approach here is to transfer your lengthy operation to a background thread. This leaves your user interface responsive, which also means that COM messages may work correctly. BackgroundWorker is a good tool for this.

+8
source

In my experience, this is due to a long-term task in the main window shape stream. Consider using BackgroundWorker to run a task. The immediate benefit of this would be that your user interface will not be dependent on the execution of the task. You can even examine the progress bar implementation using the ProgressChanged event.

0
source

Source: https://habr.com/ru/post/903316/


All Articles