parisisinjail

I have many methods that can enable a common Timer object. I need the Timer object to act on a referenced object passed in from the caller. Can I pass this into the _Tick method's args somehow or is there a more correct way to be doing this



Re: Visual C# General Passing data to a Timer object's args

OmegaMan

So what you are saying is that a caller starts a timer which goes off for certain intervals. You wan the first interval to process specific data. Does it process that data on every tick or just the first

My thought is why pass info on the tick, but place the data to work with in a queue which the timer can check for by dequeing the queue....or is there something about your design that I am not seeing at this time.





Re: Visual C# General Passing data to a Timer object's args

parisisinjail

I have the timer setup as a one-shot timer, on entry it disables itself so it only gets called once per caller. So on entry of _Tick, disable the timer, get referential data from hopefully the _Tick method's args, process and exit.

I'm using the timer to introduce a delay(set by the caller) before the caller's referential data gets processed. Thats really all it's used for.

Here's a scenario to clarify -->

Caller A: Disable timer to end a previous countdown and previous caller's intended work

Caller A: Set timer interval to spec and enable timer with new info (the hopeful passed info)

Caller B: Would do the same...wiping out Caller A's delayed call and introducing it's own.

I like your idea of a queue, but not sure how well it suits my needs In my situation, only one caller ever can be in this pseudo-queue.





Re: Visual C# General Passing data to a Timer object's args

JohnWein

Use the Timer's Tag property to pass whatever you want to the Tick event.