mirror of
https://github.com/netbirdio/systray.git
synced 2026-05-22 17:08:41 -07:00
Running onReady in separate goroutine
This commit is contained in:
+14
@@ -53,8 +53,22 @@ func Run(onReady func(), onExit func()) {
|
||||
|
||||
if onReady == nil {
|
||||
onReady = func() {}
|
||||
} else {
|
||||
// Run onReady on separate goroutine to avoid blocking event loop
|
||||
origOnReady := onReady
|
||||
readyCh := make(chan interface{})
|
||||
go func() {
|
||||
<-readyCh
|
||||
origOnReady()
|
||||
}()
|
||||
onReady = func() {
|
||||
close(readyCh)
|
||||
}
|
||||
}
|
||||
systrayReady = onReady
|
||||
|
||||
// unlike onReady, onExit runs in the event loop to make sure it has time to
|
||||
// finish before the process terminates
|
||||
if onExit == nil {
|
||||
onExit = func() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user