Hi, My Windows service is able to launch threads (suing the ThreadStart delegate) in Win XP, but in Win 2003 Server it cant, it is not throwing an exception too ... the thread is simply not starting.
I made a testing Windows Service which have the same code in the (OnStart) event handler and it worked both on Win XP and Win 2003 Server, that is driving me crazy, I dont know what is wrong with my original service, why it cant start the thread.
here is the code in both my Win Service with the problem and in the testing Win Service which worked just fine:
private Thread trd;
StreamWriter sw;
int i = 0;
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
sw = new StreamWriter("c:\\TestingService.txt", true);
trd = new Thread(new ThreadStart(this.LoopingThread));
trd.IsBackground = false;
trd.Priority = ThreadPriority.Highest;
trd.Start();
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
}
private void LoopingThread()
{
while (i < 100)
{
lock (sw)
{
sw.WriteLine("hello from thread i="+i.ToString());
sw.Flush();
}
i++;
Thread.Sleep(1000);
}
}
this code is "exactly" identical on both Win Services. my Original Service (which have the problem) got many references to other DLLs, and its "Using" list is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Xml;
using System.Security.Principal;
using System.Reflection;
using System.Threading;
using System.Management;
and other using statements that is related to some confidential DLLs (3rd parties) but I am not actually creating any object ... the effective code is just what I posted up.
I cant figure out why my Win Service cant launch Threads on Win 2003 Server