defining event handler for Tick event of DispatcherTimer in windows 8 app

windows-8

Solution

almost had it :) You don't need to instantiate a new eventhandler object, you only need to point to the method that handles the event. Hence, an eventhandler.

        int timecounter = 10;
    DispatcherTimer timer = new DispatcherTimer();
    public BlankPage()
    {
        this.InitializeComponent();

        timer.Tick += timer_Tick;
    }

    protected void timer_Tick(object sender, object e)
    {
        timecounter--;
        if (timecounter == 0)
        {
            //disable all buttons here
        }
    }

Try to read up on delegates to understand events Understanding events and event handlers in C#

Problem

I am developing an application in windows 8 Visual studio 11, and I want to define an event handler for a DispatcherTimer instance as below: ``` public sealed partial class BlankPage : Page { int timecounter = 10; DispatcherTimer timer = new DispatcherTimer(); public BlankPage() { this.InitializeComponent(); timer.Tick += new EventHandler(HandleTick); } private void HandleTick(object s,EventArgs e) { timecounter--; if (timecounter ==0) { //disable all buttons here } } ..... } ``` But I get the following Error : ``` Cannot implicitly convert type 'System.EventHandler' to 'System.EventHandler<object>' ``` I am a novice developer to widows 8 apps. Would you please help me ?

Original source

Related problems