Questions tagged [queueuserworkitem]
37 questions
27
votes
1 answer
Difference between ThreadPool.QueueUserWorkItem and Parallel.ForEach?
What is the main difference between two of following approaches:
ThreadPool.QueueUserWorkItem
Clients objClient = new Clients();
List objClientList = Clients.GetClientList();
foreach (var list in objClientList)
{
…

Learner
- 3,904
- 6
- 29
- 44
5
votes
7 answers
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?

5YrsLaterDBA
- 33,370
- 43
- 136
- 210
3
votes
2 answers
Windows Service not completely starting
I made this small windows service in c# and I believe I may have done something wrong with my ThreadPool code that prevents my Windows Service from completely starting. If you must know, the windows service seems to be running perfectly only that…

Martin Ongtangco
- 22,657
- 16
- 58
- 84
3
votes
1 answer
QueueUserWorkItem() performance issues using Mono C#
I'm getting intermittent spikes in my profiler around the call to QueueUserWorkItem(). I queue roughly 20 jobs every second. Each job is roughly identical in terms of complexity. 95% of the jobs spend less than 0.01ms in the call to…

kiaran_ritchie
- 81
- 4
2
votes
2 answers
Calling Win32 QueueUserWorkItem() with a private member function
I am attempting to call a private member function (should not be available as public or protected) as a worker item with the Win32 function QueueUserWorkItem(). I know I've done this before and it was easy, but now I can't find that snippet, nor can…

BenWestbrook
- 23
- 2
2
votes
0 answers
Tracking Thread usage in .NET/IIS program
We have software that is multi-threaded. A source thread kicks off a bunch of parallel tasks (each task involving some processing and some talking to 3rd part APIs) and waits for some or all of them to complete.
Each thread takes 3-30 seconds to…

Brondahl
- 7,402
- 5
- 45
- 74
2
votes
2 answers
ThreadPool with 2 WaitCallback will sometimes be stuck
I'm trying to work with ThreadPool.QueueUserWorkItem but it seems that if i'll run 2 of them, meaning:
ThreadPool.QueueUserWorkItem(new WaitCallback(x=>function A);
ThreadPool.QueueUserWorkItem(new WaitCallback(x=>function B);
It sometimes will be…

Avi Levin
- 1,868
- 23
- 32
2
votes
2 answers
QueueUserWorkItem with COM in C++
I have a performance issue where clients are creating hundreds of a particular kind of object "Foo" in my 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…

David Gladfelter
- 4,175
- 2
- 25
- 25
2
votes
3 answers
ThreadPool.QueueUserWorkItem vs Parallel.For
I'm trying to understand the differences between Parralel.For and ThreadPool.QueueUserWorkItem.
Hardware & Software:
Intel i5 (quad core)
Windows 7 64bit prof
DotNet 4.5
Case 1 code: ThreadPool
for (int index = 0; index < 5; index++)
{
…

Fortmann
- 433
- 6
- 20
2
votes
1 answer
How to use Threadpool.QueueUserWorkItem in a windows service?
I have a windows service where I am using Threadpool.QueueUserWorkItem. The service connects to multiple client databases, grabs data, converts to XLS and send files to the corresponding FTP.
I have 3 questions regarding the code below:
Am I using…

Learner
- 3,904
- 6
- 29
- 44
2
votes
0 answers
.net 4.0 threadpool exception
the below code throw below exception when compiled with .net 4.0 ,while complied with .net 2.0, it's ok, any guy encounter with me?, please kindly help(I didn't use DateTime in the callback function)。
public void ProcessPriceUpdate()
{
…

laodenuo9527
- 61
- 2
1
vote
0 answers
Can ThreadPool.QueueUserWorkItem execute on Main Thread?
I'm trying to tackle a weird issue on SL on the Mac in a multi-threaded application. My application employs the ThreadPool to queue various different work items. I have a method HandleRequest that is only called via ThreadPool.QueueUserWorkItem(new…

sohum
- 3,207
- 2
- 39
- 63
1
vote
3 answers
Informing ThreadPool.QueueUserWorkItem about memory requirements
We are designing an application where users can set multiple tasks running simultaneously. We use ThreadPool.QueueUserWorkItem to set the tasks running. That part runs well.
We do have a problem where these tasks can consume 500MB+ of memory. We…

Walter Williams
- 944
- 3
- 11
- 25
1
vote
3 answers
Threadpool in C# too slow, is there a way to speed up it? Thread.Sleep(0) and QueueUserWorkItem issues
I am using Threadpool in a C# application that need to do some CPU-intensive work. By the way it seems too slow (EDIT: it prints out debug string "Calculating on "
+ lSubArea.X + ":" + lSubArea.Y + " "
+ lSubArea.Width + ":" +…

gc5
- 9,468
- 24
- 90
- 151
1
vote
1 answer
How does one call into COM from worker thread created with NT's QueueUserWorkItem?
I've got a set of tasks that I slaved to the NT threadpool using QueueUserWorkItem. I need to make some calls to COM from these separate threads to access data inside WMI. I'm unsure, however, how the correct calls to CoInitializeEx need to be…

Billy ONeal
- 104,103
- 58
- 317
- 552