Solved

Passing parameters thru a Timer Eventhandler

Posted on 2011-03-25
3
437 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now