twgh / xcgui

炫彩界面库. Go GUI library. Golang bindings for XCGUI, Windows GUI library, DirectUI design idea.

Home Page:https://pkg.go.dev/github.com/twgh/xcgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] 有时候启动时卡死在w,show(true) 里面,程序就不动了。

happychui opened this issue · comments

Bug 描述
对错误是什么的清晰描述。

预期行为
清晰的描述您期望发生的事情。

截图
如果可以,请添加屏幕截图以帮助解释您的问题。

系统:
系统和版本。

其他
其他想说的。

commented

init之后到run之前不要进行很耗时的操作, 可以把下面的代码加到run上面

	time.AfterFunc(time.Millisecond*10, func() {
		go func() {
		//一些耗时的操作, 比如从网络获取数据
		}()
	})
commented

另外注意如果你要在协程里操作ui的话, 使用xc.CallUT(), 在回调里操作ui, 这指的是对ui的一些写的操作和redraw等

init之后到run之前不要进行很耗时的操作, 可以把下面的代码加到run上面

	time.AfterFunc(time.Millisecond*10, func() {
		go func() {
		//一些耗时的操作, 比如从网络获取数据
		}()
	})

还没到run, show已经过不去了

把这个放到ui初始化前
runtime.LockOSThread()
defer runtime.UnlockOSThread()

这个有效,谢谢