473,394 Members | 1,828 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,394 software developers and data experts.

ThreadPool.QueueUserWorkItem worker thread quit quietly?

Hello All,

I met a strange behavior with the system threadpool. The worker thread seems
to quit in the middle of processing. Here is the code: I could see the step 1
is finished but step 2 is not finished. There was no exception. Any thoughts?
{
....
ThreadPool.QueueUserWorkItem(new WaitCallback(Process_Data), myObj)
....
}

static void Process_Data(object Data)
{
....
try
{
//step 1
...
//step 2
...
}
catch ()
{
....
}
}
Jan 14 '07 #1
3 4366
It is in the .NET 1.1. Thanks.

"FJY" wrote:
Hello All,

I met a strange behavior with the system threadpool. The worker thread seems
to quit in the middle of processing. Here is the code: I could see the step 1
is finished but step 2 is not finished. There was no exception. Any thoughts?
{
...
ThreadPool.QueueUserWorkItem(new WaitCallback(Process_Data), myObj)
...
}

static void Process_Data(object Data)
{
...
try
{
//step 1
...
//step 2
...
}
catch ()
{
...
}
}
Jan 14 '07 #2
Hi Mark,

Thanks for reply. If there is an exception in the threadpool thread, shall
the Try...Catch catch the exception? I have the Try Catch around the callback
function.

"Mark R. Dawson" wrote:
In the 1.1 version of the framework if you have an exception occur on a
thread poolthread then it will be swallowed without any notification, this is
not the same for the 2.0 version of the framework, see:
http://msdn2.microsoft.com/en-us/library/ms228965.aspx

Mark.
--
http://www.markdawson.org
"FJY" wrote:
It is in the .NET 1.1. Thanks.

"FJY" wrote:
Hello All,
>
I met a strange behavior with the system threadpool. The worker thread seems
to quit in the middle of processing. Here is the code: I could see the step 1
is finished but step 2 is not finished. There was no exception. Any thoughts?
>
>
{
...
ThreadPool.QueueUserWorkItem(new WaitCallback(Process_Data), myObj)
...
}
>
static void Process_Data(object Data)
{
...
try
{
//step 1
...
//step 2
...
}
catch ()
{
...
}
}
Jan 14 '07 #3
Your try catch would catch any exception that reached it. Is it possible
there is some other try/catch statement which is silently comsuming the
exceptions, what is happening between step1 and step2? i.e.

try
{
//do some stuff
}
catch
{
//do nothing
}

Mark.
--
http://www.markdawson.org
http://themightycoder.spaces.live.com

"FJY" wrote:
Hi Mark,

Thanks for reply. If there is an exception in the threadpool thread, shall
the Try...Catch catch the exception? I have the Try Catch around the callback
function.

"Mark R. Dawson" wrote:
In the 1.1 version of the framework if you have an exception occur on a
thread poolthread then it will be swallowed without any notification, this is
not the same for the 2.0 version of the framework, see:
http://msdn2.microsoft.com/en-us/library/ms228965.aspx

Mark.
--
http://www.markdawson.org
"FJY" wrote:
It is in the .NET 1.1. Thanks.
>
"FJY" wrote:
>
Hello All,

I met a strange behavior with the system threadpool. The worker thread seems
to quit in the middle of processing. Here is the code: I could see the step 1
is finished but step 2 is not finished. There was no exception. Any thoughts?


{
...
ThreadPool.QueueUserWorkItem(new WaitCallback(Process_Data), myObj)
...
}

static void Process_Data(object Data)
{
...
try
{
//step 1
...
//step 2
...
}
catch ()
{
...
}
}
Jan 14 '07 #4

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

Similar topics

5
by: Duane Pressley | last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up: 1.. A classic ASP page instantiates and calls...
3
by: SSonnenwald | last post by:
I have created a piece of code that uses a ThreadPool class and the QueueUserWorkItem method to add items to the the ThreadPool. What would seem to be simple I just can not figure out how to tell...
5
by: Peter Kirk | last post by:
Hi, I see in the ThreadPool documentation that the pool has a default limit of 25 threads. Is it correctly understood that this limit is for my entire application? So if I have several...
10
by: Lenn | last post by:
Hello, I have always used a certain design pattern for multithreaded Windows app; Start new worker thread from UI thread, use events to notify UI threads when something happens, update UI...
16
by: NOtcarvinSPAM | last post by:
It occurs to me that if I have a work object that gets executed via QueueUserWorkItem AND the work proc accesses only that object's instance data I STILL may have to lock because the object...
5
by: Henri | last post by:
Might sound a stupid question but need to be sure: When you call ThreadPool.QueueUserWorkItem and ThreadPool.RegisterWaitForSingleObject passing a New object as state e.g.:...
4
by: Jonathan Howard | last post by:
I am trying to create a page where multiple requests are made to a single webservice. This webservice takes a fair amount of time to process the requests so rather than making the calls one at a...
8
by: Jim Kane | last post by:
I've written a c# web service. When a request is received I need to download a potentially large file from another site. To do that I was starting a new thread using QueueUserWorkItem but to my...
1
by: gnassar | last post by:
This question is prob. extremely trivial but I can't seem to find out what is going on. I've been doing some basic work with Multithreading and Worker Threads and have determined I'd like to set up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.