Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# Timer

Options
  • 20-06-2008 12:23pm
    #1
    Registered Users Posts: 1,987 ✭✭✭


    I'm using the below code for when the form loads:
    public Form1()
            {
                InitializeComponent();
                System.Timers.Timer myTimer = new System.Timers.Timer();
                myTimer.Elapsed += new ElapsedEventHandler(sqlQuery);
                myTimer.Interval = 5000;
                myTimer.Start();
            }
    
    Only thing is that the new ElapsedEventHandler(sqlQuery); keeps giving me a warning as below and i can't figure it out!?
    No overload for 'sqlQuery' matches delegate 'System.Timers.ElapsedEventHandler'
    Can anyone help me out here!?


Comments

  • Closed Accounts Posts: 413 ✭✭sobriquet


    What is sqlQuery? The argument to 'new ElapsedEventHandler' should be the name of a method that's defined with ElapsedEventHandlers' signature, something like:
    private void sqlQuery(object sender, ElapsedEventArgs e)
    {
    }
    


  • Registered Users Posts: 2,364 ✭✭✭Mr. Flibble


    Try giving the sqlQuery function the following args:

    sqlQuery(object source, ElapsedEventArgs e)
    {
    .
    .
    }

    But leave the line
    myTimer.Elapsed += new ElapsedEventHandler(sqlQuery);
    as it is. ie. don't try and pass it source or e.


Advertisement