threadpool

asp.net ThreadPool - long running operation.

My application is a asp.net 3.5 running on iis 6 (windows 2003) This application is serving 1000's of users daily (100-500 users online). I want to send an email newsletter to customers weekly. Around 200,000 emails every time. This is the code im using: ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncProcessMailerQueue), null);...

how can I make asynchronous callbacks be processed in a different threadpool?

When doing a begin... async call, the delegate I pass is handled (according to the documentation) in the default threadpool. for instance: System.IO.Stream.BeginRead( byte[] buffer, int offset, int count, AsyncCallback callback, object state); How can I make it so that I can use a dedicated threadpool for async method handling? ...

A robust method of tracking failed workers with ThreadPool

I'm looking for a good method of tracking (counting) which workers have failed when queued with a Threadpool and using WaitHandle.WaitAll() for all threads to finish. Is Interlocking a counter a good technique or is there a more robust strategy? ...

QueueUserWorkItem with COM in unmanaged (c++)

I have a performance issue where clients are creating hundreds of a particular kind of object "Foo" in my unmanaged (not .NET) C++ application's DOM. Each Foo instance has its own asynchronous work queue with its own thread. Obviously, that doesn't scale. I need to share threads amongst work queues, and I don't want to re-invent the...

ThreadPool.QueueUserWorkItem - strange behaviour (Asp.Net)

I'm currently using ThreadPool.QueueUserWorkItem in an Asp.Net application. Basically a user uploads a file using a form with an FileUpload Control. The file can take quite a while to process which was causing a time out for the user and also making the UI unusable while the upload was processing. So I thought I'd just call my import me...

Object synchronization with using ThreadPool

I have multiple processor objects which I use with ThreadPool to use them in a paralel process. Which processor I am going to use is basically depend on the incoming data and there might be more than 2000 different types; so as soon as my app runs it creates 1-2K number of processors in a dictionary and run the one I need according to in...

How to get a second System.Thread.ThreadPool?

If I use the ThreadPool in a nested way, my application hangs: ThreadPool.QueueUserWorkItem((state) => ThreadPool.QueueUserWorkItem(Action)); How to get a second and independent ThreadPool to achieve nesting? ...

How can I use the ThreadPool without making Sub foo(o as object) each time?

Every time that I want to make a thread in the ThreadPool I make a stupid little function like Worker_O below. Sub Worker(ByVal i As Integer) 'do important stuff End Sub Sub Worker_O(ByVal o as Object) Worker(CType(o, Integer)) End Sub Sub MakeThread() Dim worker1 as new Threading.WaitCallback(AddressOf Worker_O)) Thre...

C# Can I pass more than one data into my target method when using ThreadPool?

use ThreadPool.QueueUserWorkItem (WaitCallback, Object) to start a thread with my target method and data. Can I pass more than one data into my method? the second parameter in QueueUserWorkItem (WaitCallback, Object) can be an array? ...

ASP.NET CacheDependency out of ThreadPool

In an async http handler, we add items to the ASP.NET cache, with dependencies on some files. If the async method executes on a thread from the ThreadPool, all is fine: AsyncResult result = new AsyncResult(context, cb, extraData); ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result); But as soon as we try to execut...

What is the C# equivalent of MsgWaitForMultipleObjects?

I have a Windows Form with a ListView in Report Mode. For each item in the view, I need to perform a long running operation, the result of which is a number. The way I would do this in native win32 is to create a worker thread for each item (naively; of course I won't create an unbounded number of threads) and then MsgWaitForMultipleOb...

After FileSystemWatcher fires - Thread Pool or Dedicated thread?

I am about to implement the archetypal FileSystemWatcher solution. I have a directory to monitor for file creations, and the task of sucking up created files and inserting the into a DB. Roughly this will involve reading and processing 6 or 7, 80 char text files that appear at a rate of 150mS in bursts that occur every couple of second...

Is it possible to group/isolate tasks in ThreadPool when using WaitHandle.WaitAll?

The scenario I am facing is as below. Because ThreadPool is 1 instance per process so my question is that would method 1 cancel tasks queued by method 2 after 3 seconds? http request comes in *method 1 gets executed first*: ThreadPool.QueueUserWorkItem x 3 WaitHandle.WaitAll for 3 seconds *method 2 gets executed after method 1...

Calling Thread.Abort on a thread from a ThreadPool

My co-worker is using a third-party .NET library for which we don't have the source code. We're using a ThreadPool to have a lot of threads call into this library, and occasionally one of the threads will just hang forever while the rest of them merrily chug along. So we want to use the dreaded Thread.Abort to kill such threads. I've ...

ScheduledThreadPoolExecutor and corePoolSize 0?

I'd like to have a ScheduledThreadPoolExecutor which also stops the last thread if there is no work to do, and creates (and keeps threads alive for some time) if there are new tasks. But once there is no more work to do, it should again discard all threads. I naivly created it as new ScheduledThreadPoolExecutor(0) but as a consequence, ...

Is there a way to check what's running in the .NET Thread Pool?

Normally i was creating each thread per action i wanted to do multithreaded. I was doing it like that: private Thread threadForWycena; private void someMethod() { threadForWycena = new Thread(globalnaWycena); threadForWycena.Start(); } Then when user wanted to close one of the gui's i was checking for this thread and if...

Ensuring Thread Safety

I am in the midst of writing a C# Windows Form application that processes quotes from the market through an algorithm (strategy) to create orders to a brokerage firm. That all seems to be testing fairly well until I tried to build in the capacity to run multiple strategies simultaneously with each strategy on it's own thread. At this p...

Using JMS or ThreadPool to send email messages

Hi everyone, I will like to know: I have a scenario. If a user adds a product to the system (I'm developing), there's a listener that sends a notification to the user's client base notifying of a new product added by the user. I've read this thread and (seeing I've never used JMS nor ThreadPool before) I was wondering whether I should...

What is an elegant way for calling a custom close-method on each worker-thread in a Java threadpool?

say I'm using a ExecutorService ex = Executors.newFixedThreadPool(nrofthreads); spinning up some work and waiting when it's done. However I have same Threadlocal objects in the worker-threads which need to be closed when the batch is done. Therefore, I would like to be able to call a custom close-method on all worker-threads creat...

How to only use a specific amount of threads in the threadpool at any given time

I found this question that was very useful in learning the basics of the ThreadPool. Now my questions lies in using the ThreadPool for a series of "tasks", like the Fibonacci class, but wanting to have at most n number of these tasks executing at any one time, or basically limiting these tasks as they execute in the ThreadPool to a ma...