Solved

Passing parameters thru a Timer Eventhandler

Posted on 2011-03-25
3
462 Views
Last Modified: 2012-05-11
I need to pass a custom parameter thru to the Timer.Tick event handler. I have used the EventHandler<TEventArg> but I get a type mismatch between the System.EventHandler and my derived TEventArg.

    public class telemetryEventArgs : EventArgs
    {
        MyVehicle _v;

        public telemetryEventArgs(MyVehicle vehicle)
        {
            v = vehicle;
        }
        public MyVehicle v
        {
            get { return _v; }
            set { _v = value; }
        }
    }


timeTelemetry.Tick += new EventHandler<TimeSpanEventArgs>(timeTelemetry_Tick);

Open in new window

0
Comment
Question by:ccptechs
  • 2
3 Comments
 
LVL 2

Expert Comment

by:ericpeckham
ID: 35219286
Can't you just do the following?

  timeTelemetry.Tick += timeTelemetry_Tick);
0
 
LVL 2

Accepted Solution

by:
ericpeckham earned 500 total points
ID: 35219302
Sorry, I had a rogue closing parenthesis in that last comment - should be:

timeTelemetry.Tick += timeTelemetry_Tick;

But, now that I understand better what you're trying to do, I can see I didn't get it right.  I'll be back...
0
 

Author Closing Comment

by:ccptechs
ID: 35702421
not answered
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question