473,769 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading Question

Dear:

I need to know what should I do for the following scenario:

1. Application will continously listen to a folder waiting a files to be
copied
2. so for each file copies should be a thread to process the file then
deliver the reuslts
3. the expected number of file that maybe copied at same time is more than
20,000 files.
so is using ThreadPool in this case is right solution???
if not what should I use to manage the threads?>
Nov 16 '05 #1
8 3492
Raed Sawalha <Ra*********@di scussions.micro soft.com> wrote:
I need to know what should I do for the following scenario:

1. Application will continously listen to a folder waiting a files to be
copied
2. so for each file copies should be a thread to process the file then
deliver the reuslts
3. the expected number of file that maybe copied at same time is more than
20,000 files.
so is using ThreadPool in this case is right solution???
if not what should I use to manage the threads?>


Personally I'd suggest avoiding the system threadpool, as it's easy to
accidentally deadlock it. You can easily create a custom threadpool
though - I have one you can use in my MiscUtil library.

See http://www.pobox.com/~skeet/csharp/miscutil

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
I downloading Threading DLL, so can I use it without care about thread
managing inside my program.

"Jon Skeet [C# MVP]" wrote:
Raed Sawalha <Ra*********@di scussions.micro soft.com> wrote:
I need to know what should I do for the following scenario:

1. Application will continously listen to a folder waiting a files to be
copied
2. so for each file copies should be a thread to process the file then
deliver the reuslts
3. the expected number of file that maybe copied at same time is more than
20,000 files.
so is using ThreadPool in this case is right solution???
if not what should I use to manage the threads?>


Personally I'd suggest avoiding the system threadpool, as it's easy to
accidentally deadlock it. You can easily create a custom threadpool
though - I have one you can use in my MiscUtil library.

See http://www.pobox.com/~skeet/csharp/miscutil

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
Raed Sawalha <Ra*********@di scussions.micro soft.com> wrote:
I downloading Threading DLL, so can I use it without care about thread
managing inside my program.


What do you mean by "threading DLL"?

You pretty much *always* need to care about thread management in your
program.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Oh! I just meant MiscUtil.dll, but realy I ougth to use in Managed C++ so I
did like
this
#using "C:\Utilities\M iscUtil.dll"
using namespace MiscUtil::Threa ding;

but when application loaded it throws exception that file MiscUtil.dll not
found, do u know the write way to import the DLL , because I used to import
..NET DLLs like this
#using <mscorlib.dll >
using namespace System;
#using "System.dll "
#using "System.Data.dl l"
.....etc

but with MiscUtil.dll does not work ,why?

"Jon Skeet [C# MVP]" wrote:
Raed Sawalha <Ra*********@di scussions.micro soft.com> wrote:
I downloading Threading DLL, so can I use it without care about thread
managing inside my program.


What do you mean by "threading DLL"?

You pretty much *always* need to care about thread management in your
program.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5
Raed Sawalha <Ra*********@di scussions.micro soft.com> wrote:
Oh! I just meant MiscUtil.dll, but realy I ougth to use in Managed C++ so I
did like
this
#using "C:\Utilities\M iscUtil.dll"
using namespace MiscUtil::Threa ding;

but when application loaded it throws exception that file MiscUtil.dll not
found, do u know the write way to import the DLL , because I used to import
.NET DLLs like this
#using <mscorlib.dll >
using namespace System;
#using "System.dll "
#using "System.Data.dl l"
....etc

but with MiscUtil.dll does not work ,why?


I don't know how you do it in Managed C++, I'm afraid - in C# you just
add a reference to the DLL in the project.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
moving 20,000 files at a time from one location to another. Adding threads
won't help very much (it will help a little, but not much). The reason is
that you are not thread-bound or even processor-bound... you are disk-bound.
In other words, you can't go any faster than the time it takes to move
blocks of data off of your disk (and either back onto the disk or out your
network port).

After more than a small number of threads (<12), there will be no advantage
to adding more threads... so plan to queue the requests and run through the
queue on each thread as fast as you can.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Raed Sawalha" <Ra*********@di scussions.micro soft.com> wrote in message
news:8D******** *************** ***********@mic rosoft.com...
Dear:

I need to know what should I do for the following scenario:

1. Application will continously listen to a folder waiting a files to be
copied
2. so for each file copies should be a thread to process the file then
deliver the reuslts
3. the expected number of file that maybe copied at same time is more than 20,000 files.
so is using ThreadPool in this case is right solution???
if not what should I use to manage the threads?>

Nov 16 '05 #7
Nick,

However it can give a nice sound hearing that diskhead going from left to
right all the time?

:-))

Cor
Nov 16 '05 #8
I agree Nick. I would only add that adding threads would probably not even
help a little and would only slow it down. Would need to test
implementation to be sure.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Nick Malik [Microsoft]" <ni*******@hotm ail.nospam.com> wrote in message
news:xcWAd.2576 62$5K2.166205@a ttbi_s03...
moving 20,000 files at a time from one location to another. Adding threads won't help very much (it will help a little, but not much). The reason is
that you are not thread-bound or even processor-bound... you are disk-bound. In other words, you can't go any faster than the time it takes to move
blocks of data off of your disk (and either back onto the disk or out your
network port).

After more than a small number of threads (<12), there will be no advantage to adding more threads... so plan to queue the requests and run through the queue on each thread as fast as you can.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Raed Sawalha" <Ra*********@di scussions.micro soft.com> wrote in message
news:8D******** *************** ***********@mic rosoft.com...
Dear:

I need to know what should I do for the following scenario:

1. Application will continously listen to a folder waiting a files to be
copied
2. so for each file copies should be a thread to process the file then
deliver the reuslts
3. the expected number of file that maybe copied at same time is more

than
20,000 files.
so is using ThreadPool in this case is right solution???
if not what should I use to manage the threads?>



Nov 16 '05 #9

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

Similar topics

65
6759
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
19
6486
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread interrupt is a very primitive functionality for stopping a blocked thread.
3
1494
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be killed when the import of the module is complete. Is this expected? Does python have to be in control to allow threads to run? Would it be better to arrange things such that the file is processed using PyRun_SimpleFile? David S. Harrison
4
1592
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The data-collecting piece of the code runs in a thread. 1. Open the db, and each thread writes the result immediately. (Sub-question: which is better: cursor object passed to the thread
6
555
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service and the final process(3) gets called. what am I doing wrong with the threading? by the way Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from process 1. Thanks 1)
7
318
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, Anthony Nystrom
4
1308
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to process messages coming out of a thread? I want to queue them up, but MessageQueue doesn't look like what I need. Should I just make my own queue class? If so I'll have to worry about enumerator synchronization... a pointer to a 'best practice'...
4
321
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In this method, I iniate a PROCESS and on completion, it reduces the available worker thread and continue. I have couple of questions; 1. Since I am launching multiple threads on a same method, do I have to take care of locking so that each one...
4
1604
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered threading. The instructor is of the opinion that threading is not very useful and glossed over the subject. At least he admitted that he was glossing it over. I've noticed that many of the postings on this board have to do with threading and I...
19
1807
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. Threading is a new concept for me to implement. Here is my problem. I have a system that receives xml files and records their file locations in a database. I can potentially receive thousands,
0
9424
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,...
1
10000
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
9866
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
8879
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
7413
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
6675
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
3571
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.