473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Thread don't start

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.

Any idea? Best regards,
Ray

Sep 17 '07 #1
3 2564
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
Sep 17 '07 #2
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
Sep 18 '07 #3
On Sep 18, 1:02 am, Ray <R...@discussions.microsoft.comwrote:
Code is something like this:
<snip>

And the process definitely has access to write to everything it needs
to?
How quickly do you get to find out that a thread has started?
Can you be sure that the OnStart code has been run completely?

Jon

Sep 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
I recently replaced my Toshiba 6100 laptop running XP Pro with a Dell Latitude D810 running XP Pro; since that time an application that I developed over a year ago has stopped working. I am using...
7
by: Microsoft | last post by:
I'm trying to use threading for the first time and can't get it to work. (VB) In the page I've got: Sub Page_Load( sender As Object, e As EventArgs ) dim o as new Example.Test...
5
by: Doug Kent | last post by:
Hi, I am using a STA thread to run a COM object. On a couple of machines the thread runs fine. On another machine the thread won't start, and no exceptions are thrown. This code is running...
8
by: sir dd | last post by:
Hi, I've got a Windows-service that runs nice and smooth on my local machine, but when installed on a server it fails to start the thread inside. I can't figure out what's wrong. The code below...
5
by: taylorjonl | last post by:
I am completely baffled. I am writting a daemon application for my work to save me some time. The application works fine at my home but won't work right here at work. Basically I have a...
4
by: =?Utf-8?B?UGhpbA==?= | last post by:
I have a dll that I call to start a thread that will monitor a serial port and then process and store the data received from that port. On most every computer I have run this on, the program...
0
by: =?Utf-8?B?UmF5?= | last post by:
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...
0
by: Yue Fei | last post by:
I have a multi thread python code, threads can start immediately if I run on command line, but I can get them started right the way if I call the same code from C/C++. test code like this: from...
7
by: Brent | last post by:
Page1.aspx calls Page2.aspx like this: ---------------- Server.Execute("Page2.aspx"); --------------- Page2.aspx's Page_Load event calls a function, getMsgs().This function runs normally...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.