Hello,
here's my problem (I've been searching for a fews days already and couldn't
find a solution)
I've got a bunch of mails to create, so I'd like to queue jobs in a
threadpool (which I can do already), but once all jobs are queued, I'd like
the main thread to wait until all mails are generated.
So far I haven't found how to do that, since the threadpool doesn't provide
an adapted WaitAll method.
Could anyone help please ?
Thanks 10 5574
Hi Shad
\\\\
Threading.Threa d.Sleep(10000) ' 10 seconds
/////
I hope this helps a little bit?
Cor
"Cor" <no*@non.com> wrote in news:3f7a9ba9$0 $19776$48b97d01
@reader21.wxs.n l: Hi Shad \\\\ Threading.Threa d.Sleep(10000) ' 10 seconds ///// I hope this helps a little bit? Cor
Hmm nope,
each mail might take up to 10 seconds to generate and i can have up to
1500 of them.
So what I'd really like is a way to know when they're all done
(something else than just counting how many threads I create and then
decrementing each time working thread finishes (I can detect that with
an event)).
I have found on the web a component that implements WaitAll for a
threadpool, but it's in C# and I'd really like toi stick to VB and
understand what I'm doing.
Or is it possible to queue my main thread at the end of the threadpool,
so it takes back control when all others threads are done ?
Thanks for the tip anyway
Hi Shad,
I did not want add it this time, mostly I set this in a loop as answer
\\\\
do while eventnotbeen
application.doe vents
threading.threa d.sleep(100)
loop
/////
Cor
"Cor" <no*@non.com> wrote in news:3f7ab0ef$0 $32097$48b97d01
@reader21.wxs.n l: Hi Shad, I did not want add it this time, mostly I set this in a loop as answer \\\\ do while eventnotbeen application.doe vents threading.threa d.sleep(100) loop /////
Cor
But it's still the same problem, the point is that I don't have only one
working thread, so this cannot be done, unless there is an event raised
when the threadpool completes its last job, is that what you're saying ?
Shad,
I do it in that way yes, keep track wich threads are active, therefore I
just have a counter
when the counter is zero all threads are done.
Cor
"Cor" <no*@non.com> wrote in news:3f7ab4d5$0 $18249$48b97d01
@reader21.wxs.n l: Shad, I do it in that way yes, keep track wich threads are active, therefore I just have a counter when the counter is zero all threads are done. Cor
I see.
I was just hoping there'd be a better solution, but I guess that'll have to
do.
Thanks a lot for your help
Shad,
Create a class that represents each request going into the ThreadPool (if
you have not already done so).
One member of this class is a System.Threadin g.ManualResetEv ent object.
Your main thread needs to have an array of the ManualResetEven t objects in
each request. The main thread does a WaitHandle.Wait All on this array of
ManualResetEven t objects. Remember that ManualResetEven t inherits from
WaitHandle so it has the WaitAll method also.
Each queue job sets its ManualResetEven t when it is finished.
Of course the above means that the main thread will be blocking until all
the queue jobs are done. If the main thread is a UI thread this is NOT
desirable!
Hope this helps
Jay
"Shad" <none> wrote in message news:Xn******** **********@213. 228.0.32... Hello, here's my problem (I've been searching for a fews days already and
couldn't find a solution)
I've got a bunch of mails to create, so I'd like to queue jobs in a threadpool (which I can do already), but once all jobs are queued, I'd
like the main thread to wait until all mails are generated. So far I haven't found how to do that, since the threadpool doesn't
provide an adapted WaitAll method. Could anyone help please ? Thanks
"Cor" <no*@non.com> scripsit: \\\\ Threading.Threa d.Sleep(10000) ' 10 seconds /////
The number of "\" and "/" should be matching.
SCNR
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schrieb "Cor" <no*@non.com> scripsit: \\\\ Threading.Threa d.Sleep(10000) ' 10 seconds /////
The number of "\" and "/" should be matching.
SCNR
Aaaaaaahhhhh... ;) I read the statement 10 times and didn't find a division
operator...
--
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Battagin |
last post by:
Is there a known bug with the interaction between the HttpWebRequest and the
ThreadPool? I current spawn several HttpWebRequest's using
BeginGetResponse, and they work for a while, using worker threads from the
ThreadPool. However, eventually (relatively quickly) there become fewer and
fewer available worker threads in the pool, until there...
|
by: Duane Pressley |
last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up:
1.. A classic ASP page instantiates and calls MethodA on COM+ Class (C1).
2.. MethodA of COM+ class (C1) instantiates and calls MethodB of .NET class (N1). (Note: N1 has been registered using...
|
by: doudou-shen |
last post by:
I will use threadpool do some work with threadpool . but I haven't any
information about it . who can help me! thank a lot
|
by: orekin |
last post by:
Hi There
I have been programming C# for a couple of months and am trying to
master Threading.
I understand that ThreadPool uses background threads (see code example
in MSDN page titled 'ThreadPool Class ') .... however I would like
to ensure that all my ThreadPool threads have completed before I exit
my Main function.
|
by: Lenn |
last post by:
Hello,
I have always used a certain design pattern for multithreaded Windows app;
Start new worker thread from UI thread, use events to notify UI threads when
something happens, update UI controls using delegates through .BeginInvoke. I
came across some code samples recently where ThreadPool class is used to
start new threads.
My...
| |
by: Larry Lard |
last post by:
Just now I translated Jon Skeet's WaitHandle.WaitAny / .WaitAll
(<http://yoda.arachsys.com/csharp/threads/waithandles.shtml>) from C#
into VB.NET, and after the first go I ran into trouble:
(from the docs for WaitHandle.WaitAll)
>>
NotSupportedException The number of objects in waitHandles is greater
than the system permits.
-or-
|
by: Kevin |
last post by:
Using this:
http://msdn2.microsoft.com/en-us/library/3dasc8as(VS.80).aspx
as an example I have a question concerning the reuse of objects. In
the example 10 instances of the Fibonacci class are made and then all
put in the threadpool at once, which is well within the limits of the
threadpool.
However, what happens if you want to do...
|
by: =?Utf-8?B?RkxEYXZlTQ==?= |
last post by:
I'm developing an application that gets data from 100 sources (via telnet
connections, but you can think stock quotes from a webservice if you like).
I was planning on using the thread pool (25 at a time). I know I would start
all 100 at once and as threads finish, a new thread would become available
and the next one would start.
However,...
|
by: UltimateBanoffee |
last post by:
Hi,
I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.QueueWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all...
|
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. ...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |