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

Exit app from separate goroutine #11

Open
iaburton opened this issue Aug 10, 2016 · 1 comment
Open

Exit app from separate goroutine #11

iaburton opened this issue Aug 10, 2016 · 1 comment

Comments

@iaburton
Copy link

Hello again,

I was curious if there was a way to exit the gui thread from a separate thread? Since the "main" thread is stuck in the C loop the bulk of the application is running in one or more goroutines. However if something happens and the app needs to exit, the best I can do is tell the user, and when the other goroutines quit/exit/return the main loop gets stuck and cannot exit without user intervention (the rest of the app being "dead" at this point).

A workaround is to call os.Exit after some delay to allow defered functions in the other goroutines a chance to run, but that doesn't seem very good. I'm using lxn/walk for the Windows version and it has a Synchronize function https://godoc.org/github.com/lxn/walk#WindowBase.Synchronize to call funcs from the main thread/goroutine, is something like this possible? Thanks

@dmitshur
Copy link
Member

This is a valid question, and possibly an issue in the library. Thanks for reporting it. I agree that doing os.Exit() to hard-exit is suboptimal, since it makes it hard to rely on clean up done via deferred funcs and other lines of code that are meant to run before exiting.

I don't know the answer off the top of my head, but I'll try to look into it.

This need hasn't come up in the past, which is why it's not yet addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants