threadpool

Threadpool is getting used by windows service problem

Hi Guys, I have created a windows service which is currently having three timers. First timer is waking up every 15 sec, second timer is waking every min. and the third timer is waking everyday. THe problem is these are spawning new threads every time and one time the threadpool gets used up completely.Is ther any to just spawn 3 thread...

C# - ThreadPool vs Tasks

As some may have seen in .NET 4.0, they've added a new namespace System.Threading.Tasks which basically is what is means, a task. I've only been using it for a few days, from using ThreadPool. Which one is more efficient and less resource consuming? (Or just better overall?) ...

Threads in WCF service

Hi, there is a piece of code: class WCFConsoleHostApp : IBank { private static int _instanceCounter; public WCFConsoleHostApp () { Interlocked.Increment(ref _instanceCounter); Console.WriteLine(string.Format("{0:T} Instance nr " + _instanceCounter + " created", DateTime.Now)); } private sta...

Optimal number of items to keep queued for the thread pool in .NET?

I am building a background processing engine which supports discarding both to-be-processed and is-being-processed items. This is for usage in a winforms application that will require heavy processing of some input elements, so I'm building a queue engine where I can enqueue workload items, and when they're processed, I get notified with...

Setting minimum threads in thread pool

I have an application with 4 worker threads from the thread pool. It was waking up every 0.5 second. as written in msdn the thread pool monitors every 0,5 second to create idle threads. I set the nuber of minimum threads to 4 and it solved the problem - no more background activity all the time. My question is - I have another applicatiop...

vs2008 c#: Thread pool question

I am using the following 2 methods. Method called DoMyWork1 does scale well like it takes 6 seconds to run three of them in 3 threads. Whereas DoMyJob method does not scale at all. If one thread takes 4 seconds then it takes 13 seconds to run 3 threads. What am I doing wrong? Does file read and/or write needs special thread handling othe...

How to make the main thread wait for the other threads to complete in ThreadPoolExecutor

Hi, I am using the ThreadPoolExecutor to implement threading in my Java Application. I have a XML which I need to parse and add each node of it to a thread to execute the completion. My implementation is like this: parse_tp is a threadpool object created & ParseQuotesXML is the class with the run method. try { ...

What's the best way to have multiple threads doing work, and waiting for all of them to complete?

I'm writing a simple app (for my wife no less :-P ) that does some image manipulation (resizing, timestamping etc) for a potentially large batch of images. So I'm writing a library that can do this both synchronously and asynchronously. I decided to use the Event-based Asynchronous Pattern. When using this pattern, you need to raise an e...

Access to singleton object from another thread

I call service method using ThreadPool.QueueUserWorkItem(o => service.Method(arg1, arg2)); Service has object 'loggingService' with I was get using Spring.Net private readonly ILoggingService loggingService = ObjectBuilder.GetObjectByName("LoggingService"); 'LoggingService' class is singleton. It writes log info to log.tx...

Limiting concurrent threads equal to number of processors?

Are there any benefits to limiting the number of concurrent threads doing a given task to equal the number of processors on the host system? Or better to simply trust libraries such as .NET's ThreadPool to do the right thing ... even if there are 25 different concurrent threads happening at any one given moment? ...

Can i use boost::threadpool as a 'thread-safe queue'?

What I need is actually a thread-safe queue structure, where multiple clients keep dumping data into the queue and one working thread keeps processing and popping the queue is there any well-established solution existing in STL or Boost? I now think about using Boost::threadpool to do this. Simply set the number of parallel threads to ...

Why does Asp.Net become non-responsive from remote machines but continue to work locally?

We have an Asp.Net 2.0 web app that is running on IIS (I've tried 5.1 on XP and 6.0 on 2003 with same results) and it works briefly and then becomes non-responsive. The odd thing is that requests from the local server (using "localhost" or the ip) continue to work fine. But all page requests from other machines just time out. I don't...

Analyzing output of !threadpool and !threads in windbg

I have generated dumps on four servers and am analyzing the output of !threadpool and !threads. I noticed the roughly consistent following output: 0:024> !threadpool CPU utilization 0% Worker Thread: Total: 2 Running: 0 Idle: 2 MaxLimit: 200 MinLimit: 2 Work Request in Queue: 0 Number of Timers: 27 Completion Port Thread:Total: 2 Free: ...

My threadspool just make 4~5threads. why?

I use QueueUserWorkItem() function to invoke threadpool. And I tried lots of work with it. (about 30000) but by the task manager my application only make 4~5 thread after I push the start button. I read the MSDN which said that the default number of thread limitation is about 500. why just a few of threads are made in my application? I'm...

ThreadPool SetMaxThreads and SetMinThreads Magic Number

Is there a magic number or formula for setting the values of SetMaxThreads and SetMinThreads for ThreadPool? I have thousands of long-running methods that need execution but just can't find the perfect match for setting these values. Any advise would be greatly appreciated. ...

Maximum queued elements in ThreadPool.QueueUserWorkItem

I set the max thread to 10. Then I added 22000 task using ThreadPool.QueueUserWorkItem. It is very likely that not all the 22000 task was completed after running the program. Is there a limitation how many task can be queued for avaiable threads? ...

Threading to Parallelize Synchronous IO in .Net

Currently I'm in the process of designing the messaging system for my application (which uses AMQP on the backend via RabbitMQ). There are going to be multiple instances where a method can get data from multiple sources at the same time (ie. doesn't have to be sequential queries). Originally, I was going to use the ThreadPool and QueueU...

Java Thread - weird Thread.interrupted() and future.cancel(true) behaviour

Hi all, I want to manage a list of Futures objects returned by my TaskExecutor. I've something like this List<Future<String>> list void process(ProcessThis processThis) { for ( ...) { Future<String> future = taskExecutor.submit(processThis); list.add(future) } } void removeFutures() { for(Future fu...

multi-threading question for large batch process

We have a batch process consisting of about 5 calculations that happens on each row of data (20 million rows total). Our production server will have around 24 processors with decent CPUs. Performance is critical for us. Assuming that our algorithms are pretty efficient, what would be the best way to achieve maximum time performance fo...

How would you change my Heartbeat process written in C#?

I'm looking at implementing a "Heartbeat" process to do a lot of repeated cleanup tasks throughout the day. This seemed like a good chance to use the Command pattern, so I have an interface that looks like: public interface ICommand { void Execute(); bool IsReady(); } I've then created several tasks that I want...