473,785 Members | 2,987 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 6379
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
2135
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
3645
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
2031
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
4054
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
9645
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...
1
10092
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
9950
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
8973
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
7499
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
6740
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();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
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.