Click here to Skip to main content
15,923,689 members
Home / Discussions / C#
   

C#

 
GeneralRe: A Service to Kill Processes Pin
kingletas18-Oct-07 5:04
kingletas18-Oct-07 5:04 
AnswerRe: A Service to Kill Processes Pin
Ian MacLean18-Oct-07 5:07
Ian MacLean18-Oct-07 5:07 
QuestionReading Very Large Text File ... Pin
Davids Maguire18-Oct-07 4:06
Davids Maguire18-Oct-07 4:06 
AnswerRe: Reading Very Large Text File ... Pin
Abhijit Jana18-Oct-07 4:15
professionalAbhijit Jana18-Oct-07 4:15 
AnswerRe: Reading Very Large Text File ... Pin
Colin Angus Mackay18-Oct-07 4:16
Colin Angus Mackay18-Oct-07 4:16 
GeneralRe: Reading Very Large Text File ... Pin
Dan Neely18-Oct-07 5:39
Dan Neely18-Oct-07 5:39 
GeneralRe: Reading Very Large Text File ... Pin
Colin Angus Mackay18-Oct-07 8:10
Colin Angus Mackay18-Oct-07 8:10 
AnswerRe: Reading Very Large Text File ... Pin
Luc Pattyn18-Oct-07 4:24
sitebuilderLuc Pattyn18-Oct-07 4:24 
Hi,

you can use the Position property of streams to skip some of the data, so you could
start a few threads and give them different initial positions; I do have some remarks:

1. each thread will have to open the file in such a way that the others can also read it,
hence readonly and "shared reading"
2. if Position is not zero, the first line read will likely be a partial line, so you may
want to ignore the first line.
3. you will need a way to make each thread stop reading when it reaches the first valid
line another thread has already dealth with.
4. don't expect to gain much from large numbers of threads; two will probably help, and
four or more may well have a negative effect since overhead costs will increase
while the threads in the end may well compete for the same resources (unless processing
includes a lot of waiting on communications, or some other round-trip delays).


An alternative approach would be to have one thread that reads the entire file,
and dispatches the lines to a couple of threads for processing. This would be simpler
to organize, and maybe even better for performance, assuming your processing threads
don't need consecutive lines from the file.

Smile | :)



Luc Pattyn [Forum Guidelines] [My Articles]


this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google


GeneralRe: Reading Very Large Text File ... Pin
Davids Maguire18-Oct-07 4:32
Davids Maguire18-Oct-07 4:32 
GeneralRe: Reading Very Large Text File ... Pin
Luc Pattyn18-Oct-07 4:38
sitebuilderLuc Pattyn18-Oct-07 4:38 
AnswerRe: Reading Very Large Text File ... Pin
leppie18-Oct-07 4:52
leppie18-Oct-07 4:52 
AnswerRe: Reading Very Large Text File ... Pin
Ennis Ray Lynch, Jr.18-Oct-07 10:01
Ennis Ray Lynch, Jr.18-Oct-07 10:01 
QuestionoleDB, Odbc, DataBase Pin
half-life18-Oct-07 3:37
half-life18-Oct-07 3:37 
AnswerRe: oleDB, Odbc, DataBase Pin
Abhijit Jana18-Oct-07 3:48
professionalAbhijit Jana18-Oct-07 3:48 
GeneralRe: oleDB, Odbc, DataBase Pin
half-life18-Oct-07 3:55
half-life18-Oct-07 3:55 
GeneralRe: oleDB, Odbc, DataBase Pin
Abhijit Jana18-Oct-07 4:09
professionalAbhijit Jana18-Oct-07 4:09 
AnswerRe: oleDB, Odbc, DataBase Pin
J4amieC18-Oct-07 3:54
J4amieC18-Oct-07 3:54 
JokeRe: oleDB, Odbc, DataBase Pin
Abhijit Jana18-Oct-07 4:10
professionalAbhijit Jana18-Oct-07 4:10 
QuestionThreading Problem- a thread that calls two functions Pin
gizmokaka18-Oct-07 3:33
gizmokaka18-Oct-07 3:33 
AnswerRe: Threading Problem- a thread that calls two functions Pin
Luc Pattyn18-Oct-07 4:15
sitebuilderLuc Pattyn18-Oct-07 4:15 
GeneralRe: Threading Problem- a thread that calls two functions Pin
gizmokaka18-Oct-07 5:11
gizmokaka18-Oct-07 5:11 
GeneralRe: Threading Problem- a thread that calls two functions Pin
Luc Pattyn18-Oct-07 5:27
sitebuilderLuc Pattyn18-Oct-07 5:27 
GeneralRe: Threading Problem- a thread that calls two functions Pin
gizmokaka18-Oct-07 5:48
gizmokaka18-Oct-07 5:48 
GeneralRe: Threading Problem- a thread that calls two functions Pin
Luc Pattyn18-Oct-07 6:58
sitebuilderLuc Pattyn18-Oct-07 6:58 
QuestionAny idea about how to work with IM? Pin
baburman18-Oct-07 3:33
baburman18-Oct-07 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.