473,651 Members | 3,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ThreadPool.Queu eUserWorkItem 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.Queu eUserWorkItem(n ew WaitCallback(Pr ocess_Data), myObj)
....
}

static void Process_Data(ob ject Data)
{
....
try
{
//step 1
...
//step 2
...
}
catch ()
{
....
}
}
Jan 14 '07 #1
3 4380
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.Queu eUserWorkItem(n ew WaitCallback(Pr ocess_Data), myObj)
...
}

static void Process_Data(ob ject 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.Queu eUserWorkItem(n ew WaitCallback(Pr ocess_Data), myObj)
...
}
>
static void Process_Data(ob ject 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.Queu eUserWorkItem(n ew WaitCallback(Pr ocess_Data), myObj)
...
}

static void Process_Data(ob ject 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
2755
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 MethodA on COM+ Class (C1). 2.. MethodA of COM+ class (C1) instantiates and calls MethodB of .NET class (N1). (Note: N1 has been registered using RegASM and is present in the GAC). 3.. MethodB of .NET class (N1) uses the...
3
5222
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 if all of the threads in the threadpool that I queued have completed. Does anyone have a way???? Any help would be appreciated. Thanks, Scott
5
1699
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 worker-threads each using "ThreadPool.QueueUserWorkItem" then the limit is spread over all my worker-threads - so if "worker-thread-1" currently has 20 calls in progress then there are only 5 thread-pool threads available for "worker-thread-2" ?
10
8767
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 controls using delegates through .BeginInvoke. I came across some code samples recently where ThreadPool class is used to start new threads. My questions; 1. what's the difference? 2. Any performance benefits?
16
2626
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 constructor ran in a different thread. That therefpre means that without a lock the threadpool thread might not get the correct view of the instance data. (Specifically, it might still be seen as null). Has this ever come up before? Thanks,
5
6370
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.: ThreadPool.QueueUserWorkItem(AddressOf MyCallBack, New MyObject(myArg1, myArg2)) the new object MyObject is instantiated just before QueueUserWorkItem is called, and not just before MyCallBack is called, isn't it?
4
2395
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 time I'd like to create a new thread for each call. I tested this in a stand alone application with no problems at all. My problem is that when I try using the System.Threading.Threadpool class inside the aspx page, nothing happens. I add a...
8
1619
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 surprise the thread frequently vanishes before finishing it's task. Why? If I use system.threading.thread to create a thread instead of threadpool, will it suffer the same fate? Is there any downside to that approach. Other alternatives before...
1
1751
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 a minor project that has ThreadingPools. I can't seem to get it to compile whether I follow the example tutorials or I don't. Of course the latter has a higher percentage of failing :) Anyways the line that fails is:
0
8361
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8807
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2701
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 we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.