Share via

missing: type or namespace for DispatcherTimer and RoutedEventArgs

John Ertle Jr 1 Reputation point
2022-03-13T04:16:07.253+00:00

Timer function missing:

type or namespace for

DispatcherTimer and RoutedEventArgs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Alarm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void timer_Tick(object sender, EventArgs e)
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(10);
timer.Tick += timer_Tick;
timer.Start();
}

    private async void button1_Click( object sender, RoutedEventArgs e  )
    {
    MessageBox.Show( "Start timer" );

    await Task.Delay( TimeSpan.FromSeconds(10) );

    MessageBox.Show( "10 seconds later" );
    }
}

}

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.