Re: .net 2.0 : looking for a "best practice" for multi threading jobs
- From: Michael Nemtsev <nemtsev@xxxxxxx>
- Date: Fri, 23 Feb 2007 17:59:45 +0000 (UTC)
Hello Steve B.,
S> I'm building an application that follow this scenario.
S> 1. Download a file on a server with http
S> 2. Analyse this file and extract other files in one of the section of
S> the
S> file (like dependent files)
S> 3. Foreach found files, repeat the whole process.
S> The question is : how can I quickly and correctly design my code to
S> have my winform dynamic, and the pool of working threads?
S> My first reflexion was to store the whole data in a DataSet (easy
S> databinding) which can be flat (only on DataTable required).
so, you keep serialized objects?! why not to just save files on your drive?
S> I also created an abstract class "BaseAction" that is inherited by
S> two classes : "DownloadAction" and "AnalyseAction".
S> My process object defines a Queue<Action> where I add all required
S> actions.
S> But I'm confused for the next steps... how can I have multiples
S> trheads that can "Dequeue" actions? moreover, I don't know how to manage the
S> multiples threeads since sometimes I'll have only one item in te queue, and
S> this item can add new items...
You can use ThreadPool class (standard .net) or Produce/consummer pattern
http://www.yoda.arachsys.com/csharp/threads/threadpool.shtml
http://groups.google.ru/group/microsoft.public.dotnet.framework/browse_thread/thread/a33378c87b856678/abc251c95cbac487
The idea is that you can dequeue your files and each tread will analyze your files dequeuing them
---
WBR, Michael Nemtsev [C# MVP]. My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it" (c) Michelangelo
.
- Follow-Ups:
- References:
- Prev by Date: Re: Include Framework 2 in Install Pack
- Next by Date: Reflection and Interfaces
- Previous by thread: .net 2.0 : looking for a "best practice" for multi threading jobs
- Next by thread: Re: .net 2.0 : looking for a "best practice" for multi threading jobs
- Index(es):