Yortw / RSSDP

Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.

Home Page:http://yortw.github.io/RSSDP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cancellation Token for SearchAsync

garybrowndev opened this issue · comments

It would be really great if SearchAsync took a cancellation token. When using this library inside of a Windows Service, you get an annoying behavior where when you try and stop the Windows service, if your code is inside the SearchAsync function, it blocks the whole app from closing until it comes out. When in the Windows Service manager, the "Stopping Service" dialog is popped up until SearchAsync finishes. This is due to, I think, the line in SearchAsync where its doing this:
await TaskEx.Delay(searchWaitTime).ConfigureAwait(false);

All you would do is add a cancellation token to the SearchAsync functions, and pass that along into the TaskEx.Delay() and that should fix it. What do you think?

Hi,

This seems like a good idea. I'd be happy to look at a PR, otherwise I'll have a look at this next time I'm in the code, but not sure when that will be, sorry.