0

i want to display NotifyIcon after elapsed time is over instead of message box

here is my code :

1.this code is in my form window :

string message = "The " + targetGrid.Rows[i].Cells[2].Value + " batch is completed!";// dataGridrow contains "00:05:22" (time) 
notify.notifyTimer(TimeSpan.Parse(rTime), message);

2.this is my notifyclass and notify is object of that class

class NotifyClass
    {
    string msg;
    public void notifyTimer(TimeSpan rts, string message)
    {
        var aTimer = new System.Timers.Timer(rts.TotalMilliseconds);
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
        aTimer.Enabled = true;
        msg = message;
    }
    private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
    {

        System.IO.Stream str = Properties.Resources.ios_notification;
        System.Media.SoundPlayer player = new System.Media.SoundPlayer(str);
        player.Play();
        MessageBox.Show(msg); **// Here i want to display notifyIcon**
        player.Stop();
    }
}

so whow to do that please help me..

1 Answers1

-1

You can find a tutorial on how to add a NotifyIcon without a form here.

All you would change to make it appear is, instead of typing notifyIcon1.Visible = true right at the start of the program, you put that command in an event.

You still need to notifyIcon1.Visible = false at the end of the execution.