You can use SendMessage to communicate between threads. For example: 
    
    
    import os, threadpool
    import wNim/[wApp, wFrame, wPanel, wStaticText]
    import winim/lean
    
    const wEvent_SetLabel = wEvent_App + 1
    
    var app = App()
    var frame = Frame(size=(200, 100))
    var panel = Panel(frame)
    panel.margin = 10
    
    var status = StaticText(panel)
    frame.center()
    frame.show()
    
    status.wEvent_SetLabel do (event: wEvent):
      status.label = $event.wParam
      status.fit
    
    proc mywhile(hwnd: HWND) {.thread.} =
      var i = 0
      while(true):
        SendMessage(hwnd, wEvent_SetLabel, WPARAM i, 0)
        i.inc
        os.sleep(1000)
    
    spawn mywhile(status.handle)
    app.mainLoop()
    
    
    Run

Here I use threadpool and spawn. To use createThread is ok.

Reply via email to