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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C# Timer

  • 20-06-2008 11:23am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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