Is there a way I can make a timer that doesnt halt the application that uses it? I'm trying to make a timer dll for use in autoplay media studio 7 and after several different attempts all my efforts are leaving me frustrated as the timer seems to halt the application till its done.
any ideas would great
Non Halting Timer
Either use a thread instead, or when you receive the #WM_TIMER message, call a thread to do the necessary work etc. You'll probably need to add some logic to ensure you don't have more than one such thread running at a time etc.
**EDIT : or do what eriansa said!
**EDIT : or do what eriansa said!

I may look like a mule, but I'm not a complete ass.
-
- User
- Posts: 22
- Joined: Wed Jan 23, 2008 6:58 am
Maybe this is what u seek
Code: Select all
Procedure proc()
Debug "proc called via Settimer thread"
EndProcedure
If OpenWindow(0,0,0,200,100,"Test",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
StringGadget(0,10,10,50,20,"1",#PB_String_Numeric)
ButtonGadget(1,10,70,50,20,"Run")
ButtonGadget(2,70,70,50,20,"Stop")
EndIf
EndIf
Repeat
Ev=WaitWindowEvent(1)
Tmr.l=ElapsedMilliseconds()
If Ev=#PB_Event_Gadget
Select EventGadget()
Case 1 ;run btn
period=Val(GetGadgetText(0))*1000
If period<1000
period=1000
EndIf
Settmr=SetTimer_(WindowID(0), 1, period, @proc()) ;start api timer thread
Debug "timer started"
Case 2 ;stop btn
If Settmr
KillTimer_(WindowID(0),Settmr); kill api timer
Settmr=0
Debug "timer stopped"
EndIf
EndSelect
EndIf
Until Ev=#PB_Event_CloseWindow
-
- User
- Posts: 22
- Joined: Wed Jan 23, 2008 6:58 am
Well, any timer created with SetTimer_() does not actually run in the background; it runs within the process which created it and is processed only when DespatchMessage_() find a #WM_TIMER message etc. The messages themselves are posted to the processes message queue 'in the background' by Windows itself, but not the actual processing thereof which will run and halt the main process etc.
I may look like a mule, but I'm not a complete ass.