{"action":"closed","issue":{"url":"https://api.github.com/repos/aritchie/bluetoothle/issues/211","repository_url":"https://api.github.com/repos/aritchie/bluetoothle","labels_url":"https://api.github.com/repos/aritchie/bluetoothle/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/aritchie/bluetoothle/issues/211/comments","events_url":"https://api.github.com/repos/aritchie/bluetoothle/issues/211/events","html_url":"https://github.com/aritchie/bluetoothle/issues/211","id":340693789,"node_id":"MDU6SXNzdWUzNDA2OTM3ODk=","number":211,"title":"WhenDisconnected not waiting correctly after CancelConnection","user":{"login":"gunpuz","id":39419120,"node_id":"MDQ6VXNlcjM5NDE5MTIw","avatar_url":"https://avatars0.githubusercontent.com/u/39419120?v=4","gravatar_id":"","url":"https://api.github.com/users/gunpuz","html_url":"https://github.com/gunpuz","followers_url":"https://api.github.com/users/gunpuz/followers","following_url":"https://api.github.com/users/gunpuz/following{/other_user}","gists_url":"https://api.github.com/users/gunpuz/gists{/gist_id}","starred_url":"https://api.github.com/users/gunpuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunpuz/subscriptions","organizations_url":"https://api.github.com/users/gunpuz/orgs","repos_url":"https://api.github.com/users/gunpuz/repos","events_url":"https://api.github.com/users/gunpuz/events{/privacy}","received_events_url":"https://api.github.com/users/gunpuz/received_events","type":"User","site_admin":false},"labels":[{"id":653391270,"node_id":"MDU6TGFiZWw2NTMzOTEyNzA=","url":"https://api.github.com/repos/aritchie/bluetoothle/labels/not%20a%20bug","name":"not a bug","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-12T15:42:21Z","updated_at":"2018-07-12T21:22:35Z","closed_at":"2018-07-12T21:22:35Z","author_association":"NONE","body":"## Please check all of the platforms you are having the issue on (if platform is not listed, it is not supported)\r\n\r\n - [] iOS\r\n - [*] Android\r\n - [] tvOS\r\n - [] macOS\r\n - [] .NET Standard\r\n - UWP IS NOT SUPPORTED DURING THE BETA PERIOD - ONLY PRs ARE WELCOME FOR NOW\r\n\r\n## Version of OS(s) listed above with issue\r\n\r\n\r\n## Version of Library\r\n6.1.2\r\n\r\n## Expected Behaviour\r\n\r\n            Device.DeviceObject.Connect();\r\n\r\n            await Device.DeviceObject.ConnectWait();\r\n\r\n            Device.DeviceObject.CancelConnection();\r\n            \r\n            await Device.DeviceObject.WhenDisconnected();\r\n\r\n\"WhenDisconnected()\" should wait for device to be at disconnected state\r\n## Actual Behavior\r\n_If applicable, please include entire exception - type, message, stacktrace_\r\n\r\nWaits forever?\r\n\r\nIntresting note:\r\nstatus change subscription should be before calling cancel connection?\r\nBut if at first cancelConnection is called and then status changes is subscribed, then status is triggered only at \"Connected\"\r\nThis code did the work (Returned after device state is disconnected), it is for disconnect and wait:\r\n\r\n            var tcs = new TaskCompletionSource<bool>();\r\n            Debug.WriteLine(await CrossBleAdapter.Current.GetConnectedDevices().Count());\r\n\r\n            IDisposable sub = null;\r\n            sub = Device.DeviceObject.WhenStatusChanged().Subscribe(status =>\r\n            {\r\n                if (status == ConnectionStatus.Disconnected)\r\n                {\r\n                    sub?.Dispose();\r\n                    tcs.TrySetResult(true);\r\n                }\r\n            });\r\n            Device.DeviceObject.CancelConnection();\r\n            \r\n            await tcs.Task;\r\n\r\n## Code of Conduct\r\n* No Library Update Requests\r\n* No Timeline Requests\r\n* Please read through the documentation and FAQs\r\n* Please be respectful of my time. I put a lot of effort into my libraries.  I try to support the issue requests within a day.  I'm not psychic, so please take the time to fill out the above form as complete as possible"}}
{"actor":{"display_login":"aritchie"}}