login about faq

Could you explain the behaviour of the Disconnect() method of the SSH component? Will the Disconnect() method call end all other synchronous method calls?

I have a situation where the ChannelRead() method is called and waiting for a response, meanwhile the Disconnect() method is called on another thread.

It seems that the disconnect() method doesn’t complete until the ChannelRead() method completes? Is that right?

If so what is the best way to make the Disconnect() method not wait for the ChannelRead() method to complete?

asked May 09 at 11:36

chilkat's gravatar image

chilkat ♦♦
12.8k317367483


Chilkat objects are thread-safe because only one method call can be active at a time on a given instance of an object. Let's say there's an object ObjA and two threads have a reference to this object. One thread calls ObjA->X and the other simultaneously calls ObjA->Y. Whichever thread was first in making the call will gain the lock on the object, and the other thread must wait. If, for example, X was called first, then Y will proceed immediately after X returns.

For some objects, like the Chilkat Socket object, where we want simultaneous calls, such as for bi-directional communications, there are workarounds. For example, the socket.CloneSocket method creates a new object that shares the same underlying connection. This allows for one thread to be writing while the other is reading simultaneously. (The thread-safety for the underlying socket is handled internally by Chilkat, but the thread-safety of the Chilkat object is satisfied because we now have two separate objects.)

Also, many property setters/getters can work without getting blocked if the object is locked by another thread. There is a special property named AbortCurrent that is common to all Chilkat classes that also have Async methods (because Async methods only exist for methods that might take some time to return). The AbortCurrent property can be set to true from the other thread. This would be the correct way to abort any running Chilkat method from another thread.

link

answered May 09 at 11:48

chilkat's gravatar image

chilkat ♦♦
12.8k317367483

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×106
×9
×3

Asked: May 09 at 11:36

Seen: 271 times

Last updated: May 09 at 11:48

powered by OSQA