Thread in linux

Linux specific forum
mestnyi
Addict
Addict
Posts: 1000
Joined: Mon Nov 25, 2013 6:41 am

Thread in linux

Post by mestnyi »

departs error purebasic 531

Code: Select all

Procedure MouseEvent( );*Gadget )
  Protected DesktopMouseX = DesktopMouseX()
  Protected DesktopMouseY = DesktopMouseY()
  
  ProcedureReturn
EndProcedure


Procedure ClickState()
 Protected MouseEvent = MouseEvent( )
   Debug "Thread"
EndProcedure


;-
Structure ThreadStruct
  Window.i
  Thread.i
  Delay.i
EndStructure

Procedure ThreadCallBack( *This.ThreadStruct )
  With *This
    While IsWindow( \Window )
      Delay(\Delay)
      ClickState()
    Wend 
    
    KillThread(\Thread)
  EndWith
EndProcedure

Procedure Activate( MainWindow, Delay )
  Protected *Thread.ThreadStruct = AllocateMemory( SizeOf( ThreadStruct ))
  *Thread\Thread = CreateThread( @ThreadCallBack(), *Thread ) 
  *Thread\Window = MainWindow
  *Thread\Delay = Delay
EndProcedure


OpenWindow(10, 30, 30, 250, 150, "demo",#PB_Window_SystemMenu)

Activate( 10,15 )

While IsWindow(10)
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      CloseWindow( EventWindow() )
  EndSelect
Wend

; IDE Options = PureBasic 5.42 LTS (Linux - x86)
; CursorPosition = 34
; FirstLine = 26
; Folding = --
; EnableUnicode
; EnableXP
User avatar
mk-soft
Always Here
Always Here
Posts: 5406
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Thread in linux

Post by mk-soft »

"DesktopMouseXY" work only on Main-scope. Some window and gadget functions don´t work into a threads. Use PostEvents.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
mestnyi
Addict
Addict
Posts: 1000
Joined: Mon Nov 25, 2013 6:41 am

Re: Thread in linux

Post by mestnyi »

"DesktopMouseXY" work only on Main-scope. Some window and gadget functions don´t work into a threads. Use PostEvents.
Thank you very much, so really works, thanks again. :)
Post Reply