mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 04:29:35 +08:00
[v2] Do not block during processing of messages
On windows blocking here results in a blocked main thread and a blocked webview.
This commit is contained in:
parent
ec1a535acb
commit
155f1fde49
@ -239,6 +239,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
// return
|
||||
//}
|
||||
|
||||
go func() {
|
||||
result, err := f.dispatcher.ProcessMessage(message, f)
|
||||
if err != nil {
|
||||
f.logger.Error(err.Error())
|
||||
@ -256,6 +257,8 @@ func (f *Frontend) processMessage(message string) {
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
|
@ -24,11 +24,6 @@ import "C"
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend/assetserver"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
@ -36,6 +31,12 @@ import (
|
||||
"sync"
|
||||
"text/template"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend/assetserver"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
type Frontend struct {
|
||||
@ -235,6 +236,8 @@ func (f *Frontend) processMessage(message string) {
|
||||
//}
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
result, err := f.dispatcher.ProcessMessage(message, f)
|
||||
if err != nil {
|
||||
f.logger.Error(err.Error())
|
||||
@ -252,6 +255,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
|
@ -259,7 +259,9 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Quit() {
|
||||
winc.Exit()
|
||||
// Exit must be called on the Main-Thread. It calls PostQuitMessage which sends the WM_QUIT message to the thread's
|
||||
// message queue and our message queue runs on the Main-Thread.
|
||||
f.mainWindow.Invoke(winc.Exit)
|
||||
}
|
||||
|
||||
func (f *Frontend) setupChromium() {
|
||||
@ -398,6 +400,8 @@ func (f *Frontend) processMessage(message string) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
result, err := f.dispatcher.ProcessMessage(message, f)
|
||||
if err != nil {
|
||||
f.logger.Error(err.Error())
|
||||
@ -415,6 +419,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
|
Loading…
Reference in New Issue
Block a user