I have some hundred files (or webpages, just for example sake) which i have
to process
for some business logic. I have to read this files and do some thing as per
the given requirement.
I thought of using threads to do this. So, i tried to create some 10 threads
which concurrently
read the files and give it back to my business logic layer. A static
function will take a parameter which is a file name
and give it to the callback function (async mode) which will read and do all
the stuff....
Now, the issue is all my threads are ending before the operation is over. I
tried using Monitor.Wait, nothing happens properly.
I request you guys to give me some sample code or article which could be the
same kind
Thanks in Advance
Vadivel Kumar 4 1079
Vadivel,
I can see creating one thread to do the work so that any GUI you have
doesn't hang up. Do you have reason to believe that if you did all of
the work on one thread then that thread would be spending a lot of time
in a waiting state? Try that approach first. If the CPU is well
utilized then it won't buy you much to use more threads.
Brian
Vadivel Kumar wrote: I have some hundred files (or webpages, just for example sake) which i have to process for some business logic. I have to read this files and do some thing as per the given requirement.
I thought of using threads to do this. So, i tried to create some 10 threads which concurrently read the files and give it back to my business logic layer. A static function will take a parameter which is a file name and give it to the callback function (async mode) which will read and do all the stuff....
Now, the issue is all my threads are ending before the operation is over. I tried using Monitor.Wait, nothing happens properly.
I request you guys to give me some sample code or article which could be the same kind
Thanks in Advance Vadivel Kumar
Try the Join() method on the Thread object.
Regards
Senthil
Vadivel Kumar <do********@spam-i-love-u.com> wrote: I have some hundred files (or webpages, just for example sake) which i have to process for some business logic. I have to read this files and do some thing as per the given requirement.
I thought of using threads to do this. So, i tried to create some 10 threads which concurrently read the files and give it back to my business logic layer. A static function will take a parameter which is a file name and give it to the callback function (async mode) which will read and do all the stuff....
Now, the issue is all my threads are ending before the operation is over. I tried using Monitor.Wait, nothing happens properly.
I request you guys to give me some sample code or article which could be the same kind
Have a look at http://www.pobox.com/~skeet/csharp/threads
If that doesn't help you, try to write a short but complete program
that demonstrates the problem.
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
However, I'd go along with what Brian said - having lots of threads
probably isn't a good idea.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks Jon, for giving me a guidelines of how to post good.
But, I got solved the problem and it is working fine.
Thanks & Regards
Vadivel Kumar
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Vadivel Kumar <do********@spam-i-love-u.com> wrote: I have some hundred files (or webpages, just for example sake) which i have to process for some business logic. I have to read this files and do some thing as per the given requirement.
I thought of using threads to do this. So, i tried to create some 10 threads which concurrently read the files and give it back to my business logic layer. A static function will take a parameter which is a file name and give it to the callback function (async mode) which will read and do all the stuff....
Now, the issue is all my threads are ending before the operation is over. I tried using Monitor.Wait, nothing happens properly.
I request you guys to give me some sample code or article which could be the same kind
Have a look at http://www.pobox.com/~skeet/csharp/threads
If that doesn't help you, try to write a short but complete program that demonstrates the problem. See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that.
However, I'd go along with what Brian said - having lots of threads probably isn't a good idea.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: OutsiderJustice |
last post by:
Hi All,
I can not find any information if PHP support multi-thread (Posix
thread) or not at all, can someone give out some information? Is it
supported? If yes, where's the info? If no, is it...
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
...
|
by: cody |
last post by:
What are multi file assemblies good for?
What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a
single multi file assembly (A.DLL+A.NETMODULE)?
|
by: Joe |
last post by:
I have 2 multi-list boxes, 1 displays course categories based on a
table called CATEGORIES. This table has 2 fields CATEGORY_ID,
CATEGORY_NAME
The other multi-list box displays courses based on...
|
by: bobwansink |
last post by:
Hi, I'm relatively new to programming and I would like to create a C++
multi user program. It's for a project for school. This means I will
have to write a paper about the theory too. Does anyone...
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
Wide character and multi-byte character are two popular encoding schemes on
Windows. And wide character is using unicode encoding scheme. But each time I
feel confused when...
|
by: Sabri.Pllana |
last post by:
We apologize if you receive multiple copies of this call for papers.
***********************************************************************
2008 International Workshop on Multi-Core Computing...
|
by: mknoll217 |
last post by:
I am recieving this error from my code:
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part identifier...
|
by: Aussie Rules |
last post by:
Hi,
I have a site that Iwant to either display my text in english or french,
based on the users prefernces ?
I am new to webforms, but I know in winforms, this is pretty easy with a
resource...
|
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= |
last post by:
Hi,
consider the attached code.
Serializing the multi-dimensional array takes about 36s
vs. 0.36s for the single-dimensional array.
Initializing the multi-dimensional array takes about 4s...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
| |