Closed ChrisWhiten closed 10 years ago
Yikes. Monday morning mess-up here. The issue is that the NetMQContext doesn't get disposed (.Dispose() should be called on it). I'm not sure if not disposing of that object should hold up the lifetime of the process or not, but this is just a misuse of the library, I think.
You should not dispose the socket from another thread, the socket must be used on one thread only (creating, using and disposing).
You can however dispose the context. Anyway, dispose the context on the main thread and wrap the socket with using in the killThreadTest.
Diposing the context will make the RecieveString to throw an TerminatingException which you can catch.
On Mon, Mar 17, 2014 at 3:40 PM, Chris Whiten notifications@github.comwrote:
I have a thread dedicated to watching a queue with NetMQ for incoming messages and performing various actions with the incoming data. Essentially, it just continuously loops, calling NetMQSocket.ReceiveString() and passing off the result to a separate service. I'm finding that when I want to kill the thread, things are not getting cleaned up properly and the thread is actually never killed. This is problematic when the containing process is launched as a service, since "stopping" the service won't necessarily kill the actual process.
The code that I'm using as a test is in a gist here: https://gist.github.com/ChrisWhiten/9599137
I've tried different options for cleanup (different variations of .Close(), .Unbind(), .Disconnect(), .Dispose()) but none of the variations I have tried have resulted in the thread being correctly exited. What is the right way to handle the thread being destroyed while waiting on a .ReceiveString() call?
Reply to this email directly or view it on GitHubhttps://github.com/zeromq/netmq/issues/117 .
I have a thread dedicated to watching a queue with NetMQ for incoming messages and performing various actions with the incoming data. Essentially, it just continuously loops, calling NetMQSocket.ReceiveString() and passing off the result to a separate service. I'm finding that when I want to kill the thread, things are not getting cleaned up properly and the thread is actually never killed. This is problematic when the containing process is launched as a service, since "stopping" the service won't necessarily kill the actual process.
The code that I'm using as a test is in a gist here: https://gist.github.com/ChrisWhiten/9599137
I've tried different options for cleanup (different variations of .Close(), .Unbind(), .Disconnect(), .Dispose()) but none of the variations I have tried have resulted in the thread being correctly exited. What is the right way to handle the thread being destroyed while waiting on a .ReceiveString() call?