Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to elegantly close DNS Server? #69

Closed
Enovale opened this issue Feb 21, 2020 · 1 comment
Closed

How to elegantly close DNS Server? #69

Enovale opened this issue Feb 21, 2020 · 1 comment

Comments

@Enovale
Copy link

Enovale commented Feb 21, 2020

Apologies if I'm simply just not fluent enough with .NET async to know this myself, but I can't figure out a nice way to make the server stop listening asynchronously besides just terminating the app. In my application I want the server running in another thread but that allows no way to stop the server.

What i've tried:
I'm using the ServerExample (mostly, it's insignificantly modified) in an async function.
I've messed around with GetAwaiter()s and Task.Run() and researched CancellationTokens but the former just doesnt seem to allow cancelling the task and the latter requires I edit the source code of the library.

What's the recommended (if any) way to do this?

@kapetan
Copy link
Owner

kapetan commented Mar 13, 2020

The DnsServer implements the IDisposable interface, so you can just call DnsServer.Dispose to termintate the server.

@kapetan kapetan closed this as completed Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants