Blocking threads - growing memory
-
Hello, I have an annoying issue where I could use some advice. I created a small windows service which uses at standard time-intervals different COM components. Every time the COM components are instantiated in their own thread, the required methods are invoked and the COM components are subsequently released and their threads end, the main thread can then evaluate the result of each COM component's action. For some COM components(third party) a problem occurs from time to time and the instantiation of the COM object blocks the thread. Even calling an Abort on these threads is not possible because doing that causes the main-thread to block. The COM components are simply instantiated using:
System.Activator.CreateInstance(comType); //here it blocks when it goes wrong (not always)
The comType is gotten using:Type comType = Type.GetTypeFromProgID(sComName); //sComName is the name of the COM component
If this blocking happens frequently, the memory of the process increases steadily due to all the blocked threads that I can't stop. So what I need is an ability to use the COM components, and still be able to clean up the threads in case such a block occurs. Does anyone have any ideas how I could accomplish that? Regards, Davy -
Hello, I have an annoying issue where I could use some advice. I created a small windows service which uses at standard time-intervals different COM components. Every time the COM components are instantiated in their own thread, the required methods are invoked and the COM components are subsequently released and their threads end, the main thread can then evaluate the result of each COM component's action. For some COM components(third party) a problem occurs from time to time and the instantiation of the COM object blocks the thread. Even calling an Abort on these threads is not possible because doing that causes the main-thread to block. The COM components are simply instantiated using:
System.Activator.CreateInstance(comType); //here it blocks when it goes wrong (not always)
The comType is gotten using:Type comType = Type.GetTypeFromProgID(sComName); //sComName is the name of the COM component
If this blocking happens frequently, the memory of the process increases steadily due to all the blocked threads that I can't stop. So what I need is an ability to use the COM components, and still be able to clean up the threads in case such a block occurs. Does anyone have any ideas how I could accomplish that? Regards, DavyGDavy wrote:
Does anyone have any ideas how I could accomplish that?
An ugly workaround, but you could consider putting them in a separate app and using IPC to communicate with the COM-component. Once the app seems to hang, you kill it :)
I are Troll :suss: