Page 1 of 1
Posted: Wed Sep 11, 2002 12:46 pm
by BackupUser
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
Posted: Wed Sep 11, 2002 12:48 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
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?
Do the processing in a thread. Check the thread library in the manual.
Posted: Wed Sep 11, 2002 12:55 pm
by BackupUser
Restored from previous forum. Originally posted by anil.
Thanks Pupil! That was a very quick answer indeed! I shall take a look at Thread immediately. Thanks again.
Cheers,
Anil
Posted: Wed Sep 11, 2002 8:15 pm
by BackupUser
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.
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
Regards,
Benny
http://www.benny.zeb.be
Posted: Thu Sep 12, 2002 12:46 am
by BackupUser
Restored from previous forum. Originally posted by anil.
It worked perfectly with Thread! I shall take a look at timers too. Thanks!