Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Who can help me with this multithreading question in C#?

Hey, guys, I have a problem with multithreading. Here's my code:

Thread ExtractIt = new Thread( new ThreadStart( ExtractFile ) );

ExtractIt.Start();

this.label3.Text="Status: Extracting dictionary file. Please wait";

At this point my program is extracting a larger text file in a thread.

Now I want to wait for the thread to exit and then print out "Files extracted successfully" or something like this in label3. Important: I do not want to lock the program. I had no success using Thread.Join(); cause this prints the success message correctly but locks the program while thread is active.

Writing this directly into the thread procedure results in a error that I can't access label3 from another thread than the thread I created it with (means: the main thread).

Is there anyone who can help?

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    Have you tried using Events? How are you extracting the files. Just check the objects event's list. You must have someting like process finished or something. YOu can also try an error checking. like if your repeating the reads to the file, when the file is done extracting, it can just execute your code to print completed.

Still have questions? Get your answers by asking now.