|
-
May 22nd, 2007, 03:19 PM
#1
Thread Starter
Junior Member
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.
-
May 22nd, 2007, 03:22 PM
#2
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
This is a vb.net forum, that belongs in the c# forum
-
May 22nd, 2007, 03:22 PM
#3
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();
}
-
May 22nd, 2007, 03:28 PM
#4
Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))
-
May 22nd, 2007, 03:31 PM
#5
Thread Starter
Junior Member
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 )
Anyway that's what i did but i have that message:
"ScanForDongle_Elapsed(object sender, System.Timers.ElapsedEventArgs e) referenced without parentheses"
-
May 22nd, 2007, 06:38 PM
#6
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);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|