Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

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 Antwort

Relevanz
  • vor 1 Jahrzehnt
    Beste Antwort

    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.

Haben Sie noch Fragen? Jetzt beantworten lassen.