michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
409 stars 114 forks source link

UnobservedTaskException caused by StreamingHueClient.AutoUpdate #173

Closed mgpreston closed 5 years ago

mgpreston commented 5 years ago

The AutoUpdate method in StreamingHueClient creates an internal Task, which is never awaited. As the call to Send inside of it can, under some circumstances, throw an exception (e.g. after calling Close), it's possible to get an unobserved task exception from TaskScheduler.UnobservedTaskException.

Would it be possible to return the internal Task object from AutoUpdate, so it can be awaited and any exceptions observed?

https://github.com/Q42/Q42.HueApi/blob/d911b75fd40ad44a65b920b085a7a7482064199f/src/Q42.HueApi.Streaming/StreamingHueClient.cs#L100

michielpost commented 5 years ago

Ok, I made a change to return the task. You can await it, but it will keep running forever until the AutoUpdate is cancelled.

mgpreston commented 5 years ago

Perfect, thank you!