Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All,

I am defining Tick Event....n getting this error.

doubleClickTimer.Tick += new EventHandler(doubleClickTimer_Tick((Object)currChannel,null));



Thanks
Posted
Updated 21-Dec-17 23:40pm

Hi,

did you defined "doubleClickTimer_Tick" this method in your code or .cs file?
 
Share this answer
 
Comments
KIDYA 26-Dec-11 0:57am    
Yes I defined it. like
public void doubleClickTimer_Tick(object sender, EventArgs e)
KIDYA 26-Dec-11 1:03am    
doubleClickTimer.Tick += new EventHandler(doubleClickTimer_Tick);
if i write like this then it works fine but i have to pass int value to this handler.So I'm passing int value thr' sender.
Make sure doubleClickTimer_Tick is a method in your code.
 
Share this answer
 
Comments
KIDYA 26-Dec-11 0:56am    
Yes I defined it. like
public void doubleClickTimer_Tick(object sender, EventArgs e)
This is a stone-age syntax. Use:
C#
doubleClickTimer.Tick += (sender, eventArgs) => {
   // whatever you want
}
Even if you are using C# v.2 where lambda syntax was not available, anonymous methods were already available:
C#
doubleClickTimer.Tick += delegate(object sender, System.EventArgs eventArgs) {
   // same thing
}


As to the versions of C# prior to v.2, I think I can safely assume that they should not be used anymore.

Now, do you know there are two more timers, not as bad as the class System.Windows.Forms, shamelessly inaccurate, designed only for ease of use? Two other, much better classes are:

System.Threading.Timer: http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx[^],
System.Timers.Timer: http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx[^].

Finally, I have no idea why are you using a timer, but you should be warned that the timers are often misused. In most situations, the better, more reliable and easier to develop and maintain solution is using threads instead.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900