m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
Hi,
I don't know what kind of value/data I have to write instead of my ???
.......
m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???));
......
......
......
private void ScanForDongle_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
CheckDongle();
}
ps:could you give me an exemple please.
thanks.
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
This is a vb.net forum, that belongs in the c# forum
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
This is C# code and should be posten in the C# section
You shouldnt speficy any parameters at all, just the subroutines name.
C# Code:
.......
m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed);
......
......
......
private void ScanForDongle_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
CheckDongle();
}
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
Sorry guys, i have forgotten that my code was in C#, because i am mixing between C# and vb :o)
Anyway that's what i did but i have that message:
"ScanForDongle_Elapsed(object sender, System.Timers.ElapsedEventArgs e) referenced without parentheses"
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
There are two issues:
1. EventHandler is a type and you are creating an instance of that type and adding it to an event. To create an instance of a type you need to use the 'new' key word to invoke the type's constructor.
2. The Timer.Elapsed event is NOT type EventHandler so you cannot add instances of the EventHandler type to it. It is type ElapsedEventHandler so you have to add instances of the ElapsedEventHandler type to it.
Then end result is that this:
C# Code:
m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed);
becomes this:
C# Code:
m_ScanForDongle.Elapsed += new System.Timers.ElapsedEventHandler(ScanForDongle_Elapsed);