Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing parameters thru a Timer Eventhandler

Posted on 2011-03-25
3
Medium Priority
?
485 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 1000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

876 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