Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Threads (handlers) issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
csharpula csharp - 12 Mar 2008 13:48 GMT
Hello,
I got the following question , part of my future application I will run
number of threads according to number of enteries in input xml file. How
can I dynamically build handlers which will wait for those threads if I
don't know before the runtime how many threads will be?

Thank u!
Jon Skeet [C# MVP] - 12 Mar 2008 13:55 GMT
> I got the following question , part of my future application I will run
> number of threads according to number of enteries in input xml file. How
> can I dynamically build handlers which will wait for those threads if I
> don't know before the runtime how many threads will be?

What exactly do you mean by "handlers"? Consider how you'd do it if you
knew to start with that you'd use 15 threads. Once you know that, it
will probably be easy to take 15 and make it n.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

csharpula csharp - 12 Mar 2008 14:06 GMT
I don't know how many threads will be,it depends on my xml input. How
can I deal with it?
Jon Skeet [C# MVP] - 12 Mar 2008 14:13 GMT
> I don't know how many threads will be,it depends on my xml input. How
> can I deal with it?

As I said, work out how you'd handle it if you *do* know how many
threads it'll be - taking 15 as an example - then adapt it so that you
can pass in the number of threads as a parameter.

What would you do with 15 threads?

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

csharpula csharp - 12 Mar 2008 14:37 GMT
But the question is if I can dynamcally create handlers for each
upcoming thread and if this is not a problematic issue?
Jon Skeet [C# MVP] - 12 Mar 2008 14:45 GMT
> But the question is if I can dynamcally create handlers for each
> upcoming thread and if this is not a problematic issue?

Well, you still haven't said what you mean by a "handler", but yes you
can create threads dynamically. It's not a problem so long as you work
out what you actually want to do with the threads.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

csharpula csharp - 12 Mar 2008 15:21 GMT
My aim to create as much threads as will be in input and to get the
result for each one of them. How can I create dynmically those functions
which will check the thread results?
Jon Skeet [C# MVP] - 12 Mar 2008 15:28 GMT
> My aim to create as much threads as will be in input and to get the
> result for each one of them. How can I create dynmically those functions
> which will check the thread results?

Well, it's more likely that the threads will each feed results to some
central pot.

However, I *strongly* suggest you just write some prototype code with
a fixed number of threads. I really think you'll find you just don't
have the problem you're anticipating.

Jon
Peter Bromberg [C# MVP] - 12 Mar 2008 16:43 GMT
It's starting to sound like you want to study how to use the .NET Threadpool
with the QueueUserWorkItem method and a callback.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> My aim to create as much threads as will be in input and to get the
> result for each one of them. How can I create dynmically those functions
> which will check the thread results?
>
> *** Sent via Developersdex http://www.developersdex.com ***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.