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

Foreground threads preventing process from terminating #353

Closed
SkinnySackboy opened this issue Jan 11, 2020 · 6 comments
Closed

Foreground threads preventing process from terminating #353

SkinnySackboy opened this issue Jan 11, 2020 · 6 comments

Comments

@SkinnySackboy
Copy link
Contributor

SkinnySackboy commented Jan 11, 2020

During recent experimentation with NATS.Client we discovered that if we do not disconnect or dispose of an existing NATS connection, our WPF app process is prevented from shutting down. I've got a feeling that this is because NATS.Client is creating foreground threads, i.e. the IsBackground property is not set to true.

Of course under normal conditions I understand that we want to be disconnecting connections and shutting down cleanly, but on the off chance that something unexpected happens it would be nice not to have to keep the entire application process in memory.

Does anyone know whether this is done intentionally, or whether it would be possible in future versions to make sure that any explicitly instantiated threads (i.e. new Thread()) also set the IsBackground property to true?

Thanks in advance.

@ColinSullivan1
Copy link
Member

Thanks for using NATS! There wasn't any specific intention in using foreground threads - we just went with the default. We can look into this - shouldn't see a performance difference.

@SkinnySackboy
Copy link
Contributor Author

Thanks @ColinSullivan1 that sounds fair. Agreed, performance wise it should make no difference. If we really want to make it bulletproof we could also add a finalizer just in case the object never gets disposed, but setting the threads as background threads would already be a start.

Would you be happy if i made a PR or would you rather take care of it?

@ColinSullivan1
Copy link
Member

I'd certainly be happy - a PR would be welcome!

@SkinnySackboy
Copy link
Contributor Author

Excellent thanks, will take care of it.

@watfordgnf
Copy link
Collaborator

@SkinnySackboy I'm available to help with this if needed.

@SkinnySackboy
Copy link
Contributor Author

SkinnySackboy commented Jan 13, 2020

Thanks @watfordgnf I've created #354

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

3 participants