How to create timed pop-up windows using MVVM?

[ad_1]

How to create timed pop-up windows using MVVM?

System.Timers.Timer timer;
//I am using Timer class on purpose because I want to have asynchronous behavior

private void InitTimer()
{
    timer = new Timer(30000); //Check every 30 seconds
    timer.Enabled = true;
    timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
    timer.Start();
}

private void TimerElapsed(object sender, ElapsedEventArgs e)
{
    DateTime currentTime;
    string message;

    currentTime = e.SignalTime;
    foreach (Task task in tasks)
    {
        if (task.AlarmTime.CompareTo(currentTime) <= 0)
        {
            message = string.Format(“({0}) Task:n{1}”,
                task.AlarmTime.ToString(“dd/MMM/yy HH:mm”), task.Description);
            //This message needs to pop up
        }
    }
}

[ad_2]

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *