473,512 Members | 14,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Baffling .NET Threading issue.

Hi all,
Hopefully some gurus here can offer some insight into possible causes
of this problem..or at least point me in the right direction as to how
to solve it.
Consider:
_transmitThread = new Thread(new ThreadStart(TransmitLoop));
_transmitThread.Priority = ThreadPriority.Normal;
_transmitThread.Name = "Client Transmitter Loop";
_transmitThread.Start();
All seems well..right? the thing is..the TransmitLoop() function is
never executed.. it's never even started. If I check the IsAlive
property of _transmitThread later on in the program execution in the
app's main thread, the value is false.
No exception is raised, the assembly runs fine..except the worker
function is never called.
Even more troubling is that this code snippet belongs to a client
application that is deployed on ~15 servers in a network. The problem
outlined above only occurs on 2 of the servers. The remaining machines
execute the assembly correctly, the TransmitLoop() thread is running
just fine.
Has anyone ever anything something like this? Any ideas on how to find
the cause of the problem? Like I mentioned, I can't debug it because it
works fine in a debug environment, as well as most of the production
enviroments.

I suspect that some exception must be thrown deep in the framework
somewhere that is raised on a thread that isn't hooked to my code..but
I don't know how to catch it..if I can at all?
Any help / insight you could provide would be much appreciated.
Thanks,
Paul.

Aug 9 '05 #1
2 1426
In main, set up a handler for Application.ThreadException. That will catch
an unhandled exception in the new thread, and that sounds like what the
problem is assuming all is well with uses of _transmitThread in your main
thread.
_transmitThread = new Thread(new ThreadStart(TransmitLoop));
_transmitThread.Priority = ThreadPriority.Normal;
_transmitThread.Name = "Client Transmitter Loop";
_transmitThread.Start();

All seems well..right? the thing is..the TransmitLoop() function is
never executed.. it's never even started. If I check the IsAlive
property of _transmitThread later on in the program execution in the
app's main thread, the value is false.
No exception is raised, the assembly runs fine..except the worker
function is never called.
Even more troubling is that this code snippet belongs to a client
application that is deployed on ~15 servers in a network. The problem
outlined above only occurs on 2 of the servers. The remaining machines
execute the assembly correctly, the TransmitLoop() thread is running
just fine.
Has anyone ever anything something like this? Any ideas on how to find
the cause of the problem? Like I mentioned, I can't debug it because it
works fine in a debug environment, as well as most of the production
enviroments.

I suspect that some exception must be thrown deep in the framework
somewhere that is raised on a thread that isn't hooked to my code..but
I don't know how to catch it..if I can at all?
Any help / insight you could provide would be much appreciated.
Thanks,
Paul.

Aug 9 '05 #2
Don't know if this helps since I'm somewhat new to threading but
you might want to try to put:

Thread.Sleep(0)

after the Start statement. I read somewhere that the thread can't
start until the current thread yields, either by a Sleep or an
End Sub. Most of the examples I've seen just happen to do the
Start as the last instruction in a subroutine, but if you have a long
unyielding process after the Start statement your new thread may
appear not to start.
Sep 2 '05 #3

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

Similar topics

77
5209
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
3
5568
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
13
1787
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
2
304
by: paul.driegen | last post by:
Hi all, Hopefully some gurus here can offer some insight into possible causes of this problem..or at least point me in the right direction as to how to solve it. Consider:
4
1986
by: JimD | last post by:
Is this safe? Any pitfalls? I have done threading in regular C# apps, but haven't had a needs to do threading in ASP.Net, until now. The issue I have ran into is this: Our corporate portal...
2
1522
by: WXS | last post by:
When I see things in .NET 2.0 like obsoletion of suspend/resume because of the public reason MS gives of they think people are using them inappropriately.. use mutex, monitor and other...
0
3492
by: R K | last post by:
I am delevoping a Scheduler module whose functionality is to load the Scheduled Item Details every day (For this I have created a System.Threading.TimerCallBack with Timespan 1 day) in a stack. Once...
126
6609
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
1
1284
by: Tim Redfern | last post by:
Hi I'm having an issue that is probably obvious to somebody here but its baffling me.. I'm using python (2.5.1) on an embedded linux sytem system (kernel 2.6.19 I think) with only 32MB memory...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.