-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IEC104 Client Hangs On Connection.Close() #31
Comments
Hello, |
Hi again.
and I do something in ASDURecieveHandler.
I changed my code and now my Disconnect method body is like this:
and now it is OK. Should I call con.Cancel() before con.Close() ? I saw Cancel method close the Socket and because of this, I called Cancel() method before Close(). Did I do correct way? |
Your call to Close() is not within the ASDURecieveHandler, right? I guess that would cause a deadlock. But calling Cancel() should not help in that case. I'm not sure if the way "running = false" is set in one thread to signal another thread to stop is correct without any synchronization. |
Yes. That's right. I call Close() Method in button_Click event, not in ASDURecieverHandler. |
First you need to ensure that the connection object is not null before attempting to close it. What you can try then is calling the Disconnect() method, or maybe after calling Close() or Disconnect() you can call Dispose() this dispose of the connection object after closing it. |
Disconnect()? I can't find Disconnect method. |
Since the issue is coming from workerThread.Join(); You can put a condition that will wait for the worker thread to finish within a specified timeout. If the thread does not finish within the timeout, it will close the connection. |
Could it be that the connection thread is stuck in the connection handler? When you are calling the UI in the connection handler then it could be a deadlock because the workerThread.Join is also running in the UI thread. |
Hi. |
Hi.
When I call Connection.Close(); method for IEC104 Client, the system runs into hang. in the server side shows that client disconnected. but my form freezes in client side. I have Traced the Close() method and freezing occurs after execute line workerThread.Join();.
How can I solve the problem.
Thanks.
The text was updated successfully, but these errors were encountered: