-1
    protected override void OnStart(string[] args)
    {
        try
        {
            TraceService("start service");
            timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            timer.Interval = 30000;
            timer.Enabled = true;
        }
        catch (Exception ex)
        {

        }
    }

    protected override void OnStop()
    {
        try
        {
            timer.Enabled = false;
            TraceService("stopping service");
        }
        catch (Exception ex)
        {

        }
    }
    public void OnElapsedTime(object source, ElapsedEventArgs e)
    {
        try
        {
            var notification = new System.Windows.Forms.NotifyIcon()
            {
                Visible = true,
                Text = "Test Notify",
                BalloonTipTitle = "test title notify",
                BalloonTipText = "Testing"                    
            };

            notification.ShowBalloonTip(10000);
            //System.Threading.Thread.Sleep(10000);
            //notification.Dispose();
            TraceService("Another entry at " + DateTime.Now);
        }
        catch (Exception ex)
        {
            TraceService("StackTrace : " + ex.StackTrace);
            TraceService("Message : " + ex.Message);
        }
    }


}

}'

Auto notify for every 30 sec

bansi
  • 55,591
  • 6
  • 41
  • 52
Jay
  • 1
  • 1
  • simple answer. windows service cannot interact with desktop UI. You may be interested in this [SO answer](http://stackoverflow.com/questions/6204634/how-can-i-show-a-notification-area-balloon-and-icon-from-a-windows-service) – bansi Jul 13 '16 at 05:24

2 Answers2

1

A Windows Service itself can not display iterations with a desktop. Its can not show windows.

Marcius Bezerra
  • 137
  • 1
  • 2
  • 11
0

You can use a Timer for this purpose in Windows Forms applications - https://msdn.microsoft.com/en-us/library/system.windows.forms.timer(v=vs.110).aspx

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91