K
karl
I have a windows service that kicks off a 'monitor' thread which in
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors (exceptions)
to the monitor thread.
Of course, all works well on my box. Yesterday I installed the .NET
Framework 1.1 on a new server and then installed my service. It
appears that everything is starting but when I perform a netstat - a
searching for my 4 ports, I don't see them 'listening'. Via Task
Manager... I added the Thread Count column and see that 6 threads are
running. I compare this to my box and 11 threads are running. Not
sure if this even applies but I don't know how to remotely trouble
shoot this issue. I really need to figure out why these 4 threads are
starting. thanks for the help!
code snippet...
Also, this is portion of the code so if it's confusing let me know.
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
this._serviceRunning = true;
ThreadStart ts = new ThreadStart( this.Monitor );
Thread myWorkerThread = new Thread( ts );
myWorkerThread.Name = "MonitorThread";
myWorkerThread.Start();
}
within Monitor...
Hl7Listener[] hl7listener = new Hl7Listener[ls.Length];
threadArray = new Thread[ls.Length];
for (i=0;i<ls.Length;i++)
{
hl7listener = new Hl7Listener(ls.Port);
hl7listener.Priority = ls.Priority;
hl7listener.SiteMsgPrefix = ls.MsgPrefix;
threadArray = new Thread(new
ThreadStart(hl7listener.StartListening));
threadArray.Name = "HL7port"+Convert.ToString(ls.Port);
threadArray.IsBackground = true;
threadArray.Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls.Port), EventLogEntryType.Information);
}
// member variable set to false within OnStop()
while (this._serviceRunning)
{
for (i=0;i<this.threadCount;i++)
{
if (hl7listener.ExceptionString != "")
{
this.eventLog1.WriteEntry("Exception handled on on thread port " +
Convert.ToString(ls.Port) +
hl7listener.ExceptionString, EventLogEntryType.Error);
hl7listener.ExceptionString = "";
if (threadArray.IsAlive)
{
hl7listener.Stop();
threadArray.Abort();
threadArray = null;
}
threadArray = new Thread(new
ThreadStart(hl7listener.StartListening));
threadArray.Name = "HL7port"+Convert.ToString(ls.Port);
threadArray.Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls.Port), EventLogEntryType.Information);
}
}
Thread.Sleep(10000);
}
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors (exceptions)
to the monitor thread.
Of course, all works well on my box. Yesterday I installed the .NET
Framework 1.1 on a new server and then installed my service. It
appears that everything is starting but when I perform a netstat - a
searching for my 4 ports, I don't see them 'listening'. Via Task
Manager... I added the Thread Count column and see that 6 threads are
running. I compare this to my box and 11 threads are running. Not
sure if this even applies but I don't know how to remotely trouble
shoot this issue. I really need to figure out why these 4 threads are
starting. thanks for the help!
code snippet...
Also, this is portion of the code so if it's confusing let me know.
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
this._serviceRunning = true;
ThreadStart ts = new ThreadStart( this.Monitor );
Thread myWorkerThread = new Thread( ts );
myWorkerThread.Name = "MonitorThread";
myWorkerThread.Start();
}
within Monitor...
Hl7Listener[] hl7listener = new Hl7Listener[ls.Length];
threadArray = new Thread[ls.Length];
for (i=0;i<ls.Length;i++)
{
hl7listener = new Hl7Listener(ls.Port);
hl7listener.Priority = ls.Priority;
hl7listener.SiteMsgPrefix = ls.MsgPrefix;
threadArray = new Thread(new
ThreadStart(hl7listener.StartListening));
threadArray.Name = "HL7port"+Convert.ToString(ls.Port);
threadArray.IsBackground = true;
threadArray.Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls.Port), EventLogEntryType.Information);
}
// member variable set to false within OnStop()
while (this._serviceRunning)
{
for (i=0;i<this.threadCount;i++)
{
if (hl7listener.ExceptionString != "")
{
this.eventLog1.WriteEntry("Exception handled on on thread port " +
Convert.ToString(ls.Port) +
hl7listener.ExceptionString, EventLogEntryType.Error);
hl7listener.ExceptionString = "";
if (threadArray.IsAlive)
{
hl7listener.Stop();
threadArray.Abort();
threadArray = null;
}
threadArray = new Thread(new
ThreadStart(hl7listener.StartListening));
threadArray.Name = "HL7port"+Convert.ToString(ls.Port);
threadArray.Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls.Port), EventLogEntryType.Information);
}
}
Thread.Sleep(10000);
}