NotifyIcon problem
-
Hallo, I make a windows service that check new entry in a database table, if there are new entries the service show a notify icon in the system tray. all works fine but when the system tray show my icon, some applications crashes and stop to work (e.g: cics) Any suggest for me? Thanks a lot. (I hope you understand me, me english is not so good.)
-
Hallo, I make a windows service that check new entry in a database table, if there are new entries the service show a notify icon in the system tray. all works fine but when the system tray show my icon, some applications crashes and stop to work (e.g: cics) Any suggest for me? Thanks a lot. (I hope you understand me, me english is not so good.)
I can't sqy why while you don't show me your code... :)
-
I can't sqy why while you don't show me your code... :)
I'm sorry! This is the code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.ServiceProcess; using System.Text; using System.Drawing; using System.Data.SqlClient; using System.Windows.Forms; namespace Warning { public partial class Warning: ServiceBase { private System.Timers.Timer m_tTimer; private SqlConnection sqlConn; private SqlCommand sqlCmd; private SqlDataReader sqlReader; private string strSql; public Waning() { InitializeComponent(); } protected override void OnStart(string[] args) { m_tTimer.Enabled = true; m_oNotifyIcon.Visible = false; } protected override void OnStop() { m_tTimer.Enabled = false; } protected override void OnContinue() { } private int GetNewRequestes() { int newRequestes=0; //System.Diagnostics.Debugger.Break(); sqlConn = new SqlConnection("DATABASE=DBNAME;SERVER=DBSERVER;user id=user;password=xxx;"); strSql = "SELECT COUNT(*) FROM DBTable WHERE StatusID=5"; try { sqlConn.Open(); sqlCmd = new SqlCommand(strSql, sqlConn); sqlReader = sqlCmd.ExecuteReader(); sqlReader.Read(); newRequestes = sqlReader.GetInt32(0); sqlReader.Close(); } catch (Exception err) { string msg = err.Message; } finally { sqlConn.Close(); } return newRequestes; } private void m_tTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { int newRequestes = 0; //System.Diagnostics.Debugger.Break(); newRequestes = GetNewRequestes(); if (newRequestes>0) { m_oNotifyIcon.Visible = true; m_oNotifyIcon.ShowBalloonTip(60, "There are "+newRequestes.ToString()+" new requestes!", " ", ToolTipIcon.Warning); } else { m_oNotifyIcon.Visible = false; } } } }
Any idea? Thanka a lot!