473,796 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About ThreadPool.Queu eUserWorkItem and ThreadPool.Regi sterWaitForSing leObject

Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Regi sterWaitForSing leObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg1 , myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri


Nov 19 '05 #1
5 6380
Yes, a reference to a brand new MyObject object will be passed into
the method. You also have to create the object before
RegisterWaitFor SingleObject.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 13 Dec 2004 14:34:16 +0100, "Henri" <hm********@hot mail.com>
wrote:
Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Reg isterWaitForSin gleObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg 1, myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri


Nov 19 '05 #2
Thanks,
So the new object will be instantied by the main thread, and MyCallBack will
then be processed by another thread from the threadPool, right?

Henri

"Henri" <hm********@hot mail.com> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Regi sterWaitForSing leObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg1 , myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri



Nov 19 '05 #3
That's correct, Henri.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 13 Dec 2004 16:41:28 +0100, "Henri" <hm********@hot mail.com>
wrote:
Thanks,
So the new object will be instantied by the main thread, and MyCallBack will
then be processed by another thread from the threadPool, right?

Henri

"Henri" <hm********@hot mail.com> a écrit dans le message de
news:%2******* *********@TK2MS FTNGP14.phx.gbl ...
Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Regi sterWaitForSing leObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg1 , myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri




Nov 19 '05 #4
Thanks for your answers Scott :-) !

"Scott Allen" <bitmask@[nospam].fred.net> a écrit dans le message de
news:gs******** *************** *********@4ax.c om...
That's correct, Henri.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 13 Dec 2004 16:41:28 +0100, "Henri" <hm********@hot mail.com>
wrote:
Thanks,
So the new object will be instantied by the main thread, and MyCallBack willthen be processed by another thread from the threadPool, right?

Henri

"Henri" <hm********@hot mail.com> a écrit dans le message de
news:%2******* *********@TK2MS FTNGP14.phx.gbl ...
Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Regi sterWaitForSing leObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg1 , myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em is called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri





Nov 19 '05 #5

Henri wrote:
*Might sound a stupid question but need to be sure:

When you call ThreadPool.Queu eUserWorkItem and
ThreadPool.Regi sterWaitForSing leObject passing a New object as state

e.g.: ThreadPool.Queu eUserWorkItem(A ddressOf MyCallBack, New
MyObject(myArg1 , myArg2))

the new object MyObject is instantiated just before QueueUserWorkIt em
is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitFor SingleObject, isn't it?

Thanks

Henri *


-- I tried to use the RegisterWaitFor SingleObject function but delhpi
does not recognise the function variables... How did you solve this
problem.
( The WaitForSingleOb ject function is no problem)

thanks in advance

Douwe

--
Douwe
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Dec 8 '05 #6

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

Similar topics

0
2136
by: sunny | last post by:
Dear ALL: I'm writing a program about printer by C# now.I have read Duncan's article about monitor printer by VB before and followed his method. I use FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification API to monitor printer. Now I'm puzzled by the FindNextPrinterChangeNotification function ..Whenever I call this method to get a pointer of PRINTER_NOTIFY_INFO , it always return null. My code is:
3
5230
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
6
2759
by: Max Adams | last post by:
Threads and ThreadPool's If I use a ThreadPool how can I tell when a thead in the threadpool has exited? I don't want to set a global member variable I would much rather be able to act on an event Also (failing this ThreadPool issue) is it possible to create an array of Worker Threads, can anyone illustrate with code please Thanks
2
3647
by: fred | last post by:
I'm writing an application invoking asynchon methods. I envision using the .NET thread pool since it matches well my needs. There is (at least) 2 methods to do that: using ThreadPool class directely or using the BeginInvoke () of a delegate. Does anybody knows any advantages from one method to
5
1703
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" ?
2
4716
by: objectref | last post by:
hi to all folks, i want to create the following senario: i have a T1 (Thread 1) that acts like http server that receives incoming requests. From that T1, i want to spawn from T1 to Tn thread jobs and beeing able to be notified when each of these threads finished it's job.
1
747
by: pmclinn | last post by:
In the code format below, is there any way to pass in a variable to the writefiles proceedure? ThreadPool.QueueUserWorkItem(AddressOf WriteFiles) Public Sub WriteFiles(ByVal stateInfo As Object) End Sub
1
2032
by: colinjack | last post by:
Hi All, I've been using the original (non-event based) asynchronous design pattern using delegates. It works fine but performance wise I know using the ThreadPool is supposed to be far better, so I wondered if anyone had any examples of the best way to do this. I've obviously had a look myself but haven't gotten very far and although I've implemented a version myself I'm not sure its the best that can be done.
1
4055
by: robert112 | last post by:
Question... Can one not use ThreadPool.QueueUserWorkItem with an anonymous method like so: ThreadPool.QueueUserWorkItem(delegate { //perform IO bound operation. }); Why did the asp.net team create the directive async=true way of creating async pages???
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
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
10217
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...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
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
7546
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...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4114
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.