Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problems of reading file content Pin
Richard MacCutchan1-Feb-10 4:25
mveRichard MacCutchan1-Feb-10 4:25 
GeneralRe: Problems of reading file content Pin
codenoobie1-Feb-10 19:02
codenoobie1-Feb-10 19:02 
QuestionC# Vb6.0 Com Interop Pin
Q2A31-Jan-10 21:33
Q2A31-Jan-10 21:33 
AnswerRe: C# Vb6.0 Com Interop Pin
Richard MacCutchan1-Feb-10 0:18
mveRichard MacCutchan1-Feb-10 0:18 
GeneralRe: C# Vb6.0 Com Interop Pin
Thomas Krojer1-Feb-10 1:29
Thomas Krojer1-Feb-10 1:29 
GeneralRe: C# Vb6.0 Com Interop Pin
Richard MacCutchan1-Feb-10 2:00
mveRichard MacCutchan1-Feb-10 2:00 
GeneralRe: C# Vb6.0 Com Interop Pin
Thomas Krojer1-Feb-10 6:25
Thomas Krojer1-Feb-10 6:25 
GeneralRe: C# Vb6.0 Com Interop Pin
Richard MacCutchan1-Feb-10 6:34
mveRichard MacCutchan1-Feb-10 6:34 
GeneralRe: C# Vb6.0 Com Interop Pin
Thomas Krojer1-Feb-10 20:40
Thomas Krojer1-Feb-10 20:40 
GeneralRe: C# Vb6.0 Com Interop Pin
Richard MacCutchan1-Feb-10 23:22
mveRichard MacCutchan1-Feb-10 23:22 
QuestionTreeView Nodes do not update Pin
googoojkhan31-Jan-10 19:38
googoojkhan31-Jan-10 19:38 
AnswerRe: TreeView Nodes do not update Pin
googoojkhan31-Jan-10 21:14
googoojkhan31-Jan-10 21:14 
AnswerRe: TreeView Nodes do not update Pin
Alex Manolescu31-Jan-10 21:28
Alex Manolescu31-Jan-10 21:28 
GeneralRe: TreeView Nodes do not update Pin
Covean31-Jan-10 23:09
Covean31-Jan-10 23:09 
GeneralRe: TreeView Nodes do not update Pin
Alex Manolescu31-Jan-10 23:57
Alex Manolescu31-Jan-10 23:57 
QuestionDisplaying Two Crystal Reports using Single CrystalReportViewer. Pin
Sanket.Patil31-Jan-10 19:04
Sanket.Patil31-Jan-10 19:04 
AnswerRe: Displaying Two Crystal Reports using Single CrystalReportViewer. Pin
basu.sit29-Mar-10 18:51
basu.sit29-Mar-10 18:51 
QuestionAxFramerControl for powerpoint preview Pin
jafaralik31-Jan-10 18:46
jafaralik31-Jan-10 18:46 
QuestionLooping through a CSV with threads Pin
Danpeking31-Jan-10 15:50
Danpeking31-Jan-10 15:50 
AnswerRe: Looping through a CSV with threads Pin
PIEBALDconsult31-Jan-10 15:57
mvePIEBALDconsult31-Jan-10 15:57 
AnswerRe: Looping through a CSV with threads Pin
Luc Pattyn31-Jan-10 16:26
sitebuilderLuc Pattyn31-Jan-10 16:26 
GeneralRe: Looping through a CSV with threads Pin
PIEBALDconsult31-Jan-10 17:05
mvePIEBALDconsult31-Jan-10 17:05 
GeneralRe: Looping through a CSV with threads Pin
Luc Pattyn31-Jan-10 17:19
sitebuilderLuc Pattyn31-Jan-10 17:19 
GeneralRe: Looping through a CSV with threads Pin
Danpeking31-Jan-10 23:00
Danpeking31-Jan-10 23:00 
GeneralRe: Looping through a CSV with threads Pin
Luc Pattyn1-Feb-10 1:40
sitebuilderLuc Pattyn1-Feb-10 1:40 
Hi,

not tested, you should read up on all classes and methods used, then adapt whatever needs adapted, and add error handling:
StreamReader sr;
bool allDone;

void handleFileWithManyThreads(string filename, bool waitTillDone) {
    allDone=false;
    sr=File.Open(filename);
    List<Thread> threads=new List<Thread>();
    // launch N threads
    for(int i=0; i<Environment.NumberOfProcessors; i++) {
        Thread thread=new Thread();
        thread.Start(runner);
        threads.Add(thread);
    }
    if (waitTillDone) {
        // now wait for all these threads to finish
        foreach(Thread thread in threads) thread.Join();
        sr.Close();
    }
}

void runner() {
    while(!allDone) {
        string line=null;
        lock(sr) {
            line=sr.ReadLine();
            if (line==null) allDone=true;
        }
        if (line!=null) {
            // process line here
        }
    }
}


Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]


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.