{"action":"created","issue":{"url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/12","labels_url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/12/comments","events_url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/12/events","html_url":"https://github.com/skrusty/AsterNET.ARI/pull/12","id":93849580,"number":12,"title":"Use a dedicated thread and event queue to invoke the event handlers in AriClient.","user":{"login":"pragmatrix","id":1003751,"avatar_url":"https://avatars.githubusercontent.com/u/1003751?v=3","gravatar_id":"","url":"https://api.github.com/users/pragmatrix","html_url":"https://github.com/pragmatrix","followers_url":"https://api.github.com/users/pragmatrix/followers","following_url":"https://api.github.com/users/pragmatrix/following{/other_user}","gists_url":"https://api.github.com/users/pragmatrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pragmatrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pragmatrix/subscriptions","organizations_url":"https://api.github.com/users/pragmatrix/orgs","repos_url":"https://api.github.com/users/pragmatrix/repos","events_url":"https://api.github.com/users/pragmatrix/events{/privacy}","received_events_url":"https://api.github.com/users/pragmatrix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-08T17:48:18Z","updated_at":"2015-07-10T17:36:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/skrusty/AsterNET.ARI/pulls/12","html_url":"https://github.com/skrusty/AsterNET.ARI/pull/12","diff_url":"https://github.com/skrusty/AsterNET.ARI/pull/12.diff","patch_url":"https://github.com/skrusty/AsterNET.ARI/pull/12.patch"},"body":"This pull request should fix #11 and is compatible with the current AriClient interface.\r\n\r\nSome notes and concerns:\r\n\r\n- I've added `IDisposable` interface and a `Dispose()` method to AriClient that invokes `Disconnect()` so that it is obvious from the interface, that some cleanup needs to be done. \r\n- The thread / event queue is shut down in `Disconnect()`, but will be kept when an automatic reconnect happens.\r\n- The thread will keep running, if neither `Disconnect()` nor `Dispose()` is called. I found no reliable way to cancel the thread so far. The finalizer won't be called, because the thread must refer to the AriClient instance to deliver the events. One solution for that would be to deliver the AriClient instance with each event.\r\n- I've also put a lock around all members that may be changed from different threads.\r\n- I am a bit concerned that the event handler invocations are serialized now. Client code that blocks inside an event handler may behave differently, or just stall.\r\n- I did a few tests within my setup, but have not tested the examples.\r\n\r\n<!-- Reviewable:start -->\r\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/skrusty/asternet.ari/12)\r\n<!-- Reviewable:end -->\r\n"},"comment":{"url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/comments/120471421","html_url":"https://github.com/skrusty/AsterNET.ARI/pull/12#issuecomment-120471421","issue_url":"https://api.github.com/repos/skrusty/AsterNET.ARI/issues/12","id":120471421,"user":{"login":"pragmatrix","id":1003751,"avatar_url":"https://avatars.githubusercontent.com/u/1003751?v=3","gravatar_id":"","url":"https://api.github.com/users/pragmatrix","html_url":"https://github.com/pragmatrix","followers_url":"https://api.github.com/users/pragmatrix/followers","following_url":"https://api.github.com/users/pragmatrix/following{/other_user}","gists_url":"https://api.github.com/users/pragmatrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pragmatrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pragmatrix/subscriptions","organizations_url":"https://api.github.com/users/pragmatrix/orgs","repos_url":"https://api.github.com/users/pragmatrix/repos","events_url":"https://api.github.com/users/pragmatrix/events{/privacy}","received_events_url":"https://api.github.com/users/pragmatrix/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T17:36:07Z","updated_at":"2015-07-10T17:36:07Z","body":"Thank you for the review @jonasswiatek!"}}