You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By polling the global dispatcher from the queueMain hook I can successfully implement async logic in GUI thread.
This works nicely on linux with GTK, but on windows native the canvas doesn't update and remains completely black for some reason
here a minimal test
$ nim c winfail.nim # compiles and run correctly on linux, compiles but GUI hangs on windows (yet app queueMain is called) $ nim r -d:mingw --cpu:i386 winfail.nim # same result when cross compiling
winfail.nim
import asyncdispatch, random
import nigui
var
window: Window
thread: Thread[void]
asyncQueue: seq[proc () {.async.}] =@[]
procdelayAlert {.async.} =awaitsleepAsync(3000)
window.alert("Hello, World!")
procmain {.async.} =var body =newLayoutContainer(Layout_Vertical)
window.add(body)
var fooButton =newButton("fooButton")
body.add(fooButton)
fooButton.onClick =proc(event: ClickEvent) =
asyncQueue.add delayAlert
var fooLabel =newLabel("fooLabel")
body.add(fooLabel)
whiletrue:
let ransString =$rand(0..100)
echo ransString
fooLabel.text = ransString
awaitsleepAsync100prockeepWheelSpinning*() {.async.} =whiletrue:
echo"spinning"for asyncProc in asyncQueue:
asyncCheckasyncProc()
asyncQueue.setLen(0)
awaitsleepAsync100
app.init()
window =newWindow("Test")
window.show()
procasyncPoll() =
{.gcsafe.}:
poll()
app.queueMain(asyncPoll)
procasyncStart() =
{.gcsafe.}:
app.queueMain(asyncPoll)
createThread(thread, asyncStart)
asyncCheckkeepWheelSpinning()
asyncQueue.add main
app.run()
The text was updated successfully, but these errors were encountered:
By polling the global dispatcher from the queueMain hook I can successfully implement async logic in GUI thread.
This works nicely on linux with GTK, but on windows native the canvas doesn't update and remains completely black for some reason
here a minimal test
$ nim c winfail.nim
# compiles and run correctly on linux, compiles but GUI hangs on windows (yet app queueMain is called)$ nim r -d:mingw --cpu:i386 winfail.nim
# same result when cross compilingwinfail.nim
The text was updated successfully, but these errors were encountered: