Using Chilkat 22.214.171.124 for .NET 4.5 x86
I have a class that holds a global
The profiler specifically points to the m_lockImpl variable:
I use the http object in several methods and I never know when the thread might be aborted, so using a Dispose() function seemed to make the most sense. Therefore I tried to implement IDisposable into my class and force the http objects to Dispose() when necessary:
When I call dispose, the application deadlocks. Some of the threads will dispose while others enter the Dispose call and never return. I found that closing the connections first helped to alleviate this issue, but it still exists. How can I resolve this issue? Why is it deadlocking? Is there a better way to dispose of the http objects?
Jordan, the Forum is a venue for users to help each other. It is not an official support channel. Chilkat does not necessarily recognize the identity of each poster, and must prioritize responses based on who is currently under paid support. When Chilkat does recognize the poster as someone with valid support, it is treated as an official support request.
The Chilkat .NET objects are thread-safe. This means that there can only be one method call (or property access) at a time for a given object instance. If two threads try to make method calls simultaneously on the same object instance, then the one that happens to be first gains access, and the other must wait until the 1st completes.
In your case, if one thread is waiting for the call to QuickGetStr to return, then another thread that tries to call CloseAllConnections, or Dispose, must wait until the QuickGetStr completes.
To properly abort a Chilkat method call (and this is standard across all Chilkat classes that involve TCP communications, or do anything else potentially time consuming), is to use the AbortCheck event callback. Set the HeartbeatMs property to a value for the frequency of AbortCheck callbacks desired. Then, when the operation is to be aborted, set the "abort" output arg in the AbortCheck callback to true (see the online reference documentation) and the method (QuickGetStr) will abort.
answered Aug 10 '14 at 09:20