Results 1 to 6 of 6

Thread: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    23

    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.

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))

    This is a vb.net forum, that belongs in the c# forum
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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:
    1. .......
    2. m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed);
    3. ......
    4. ......
    5. ......
    6.  
    7. private void ScanForDongle_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    8. {
    9. CheckDongle();
    10. }
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed(???, ???))

    moved

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    23

    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"

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. m_ScanForDongle.Elapsed += System.EventHandler(ScanForDongle_Elapsed);
    becomes this:
    C# Code:
    1. m_ScanForDongle.Elapsed += new System.Timers.ElapsedEventHandler(ScanForDongle_Elapsed);
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width