Code is something like this:
public class MyService : System.ServiceProcess.ServiceBase
{
private ProcA oProcA;
private Thread tProcA;
private ProcB oProcB;
private Thread tProcB;
protected override void OnStart(string[] args)
{
// Process A
oProcA = new ProcA();
tProcA = new Thread(new ThreadStart(oProcA.DoProcA));
tProcA.Start();
// Process B
oProcB = new ProcB();
tProcB = new Thread(new ThreadStart(oProcB.DoProcB));
tProcB.Start();
}
}
public class ProcA
{
private System.IO.StreamWriter sw;
public ProcA()
{}
public void DoProcA()
{
for (int i=1; i<300; i++)
{
sw = System.IO.File.AppendText("c:\testA.txt");
sw.WriteLine("running ProcA");
Thread.Sleep(1000);
}
}
}
public class ProcB
{
private System.IO.StreamWriter sw;
public ProcB()
{}
public void DoProcB()
{
for (int i=1; i<300; i++)
{
sw = System.IO.File.AppendText("c:\testB.txt");
sw.WriteLine("running ProcB");
Thread.Sleep(1000);
}
}
}
Regards.
"Jon Skeet [C# MVP]" wrote:
Ray <Ra*@discussions.microsoft.comwrote:
Hello. I have a c# service with four threads. Sometimes one of them just
don't start, I don't know why. It happened with any of the four threads, and
just in production environment, not in development environment.
Well, it's hard to say anything without seeing some code.
Have you cut down the program in phases to find a minimal one that
fails? How are you diagnosing that the thread doesn't start?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too