Restored from previous forum. Originally posted by anil.
Hi,
I noticed that whenever there is a loop processing for a longer period of time, the window stops responding till the processing stops. Its like this, a window is opened, gadgets are displayed and say when a button is pressed and it starts some processing in for...next loop which takes say 60 seconds. So now for these 60 seconds, the window which triggered this event stops responding.
What is the way to prevent this? Any ideas?
Thanks,
Anil
Window not responding
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Do the processing in a thread. Check the thread library in the manual.Originally posted by anil
Hi,
I noticed that whenever there is a loop processing for a longer period of time, the window stops responding till the processing stops. Its like this, a window is opened, gadgets are displayed and say when a button is pressed and it starts some processing in for...next loop which takes say 60 seconds. So now for these 60 seconds, the window which triggered this event stops responding.
What is the way to prevent this? Any ideas?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
Hi anil,
You can use timers to, i use this as my programs must use as less cpu time as possible.
You can set the time of the 'loop' perfectly.
Regards,
Benny
http://www.benny.zeb.be
Hi anil,
You can use timers to, i use this as my programs must use as less cpu time as possible.
You can set the time of the 'loop' perfectly.
Code: Select all
Global loop, hwnd
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select message
Case #WM_TIMER
Select wparam
Case 1 ; 1 sec timer
Case 2 ; 50 ms timer
; do your stuff here
loop +1
Debug loop
If loop>100
killtimer_(hwnd,2) ; end the loop
EndIf
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
hwnd= OpenWindow(1, 200, 200, 673, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"test")
If hwnd
SetWindowCallback(@MyWindowCallback())
; -------------- timers ----------------
SetTimer_(hWnd,1,1000,0) ; 1 seconden timer
SetTimer_(hWnd,2,50,0) ; 50 milisecond timer , start the loop
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
End
Benny
http://www.benny.zeb.be
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm