Quantcast
Channel: Dynamic Timers
Viewing all articles
Browse latest Browse all 5

Dynamic Timers

$
0
0

hello all been struggling to find a way to solve a problem, i need to start a timer everytime a message is processed. each message needs its own timer.

so i need to create a new timer each time and still be able to find the timer should the user want to cancel/send straight away.

is there a way to create a queue of a structure of timers and ID numbers and have each timer when fired remove itself from the queue? or some other array like structure that i can add and remove from easily with out limitations i suspect that i can not add a structure to a queue.

Public
Structure APIObject
Public t As System.Timers.Timer
Public ID AsInteger
EndStructure
 
is the object type i wish to create and i then can set off the object to my desired timer interval each timer only fires once.
For
iCount = 0 To TheFaultList.NumElements Step 1
With TheFaultList.ListOfFaults(iCount)
If .FaultID = FaultID Then
Dim temp AsNew APIObject
temp.ID = FaultID
temp.t =
New System.Timers.Timer
temp.t.Interval = .FaultDelay
AddHandler temp.t.Elapsed, AddressOf TimerFired
aQueue.Enqueue(temp)
ExitFor
EndIf
EndWith
Next
 
Public
Sub TimerFired(ByVal sender AsObject, ByVal e As System.Timers.ElapsedEventArgs)
MyService.LogCall(TempXML)
EndSub
 
the tempxml will be populated with the appropriate details but as a student i just dont seem to grasp the technical side of this problem and i could be a million miles off or i could be very close i doubt a queue is the best way of doing it as the first in first out does not work as timers can fire at different times.
 
All help is as always much appreciated i hope the code i added (hacked up quickly my idea's) helps explain what i'm trying to do :).
 
Thanks in advance

Viewing all articles
Browse latest Browse all 5