c# - Thread has exited with code 0 but not finished it's work -


I'm new to multi-threading in C # and would like to know that it's going to behave Why:

I have one thread is asynchronous file thread to load 2 always going to do the thread still have to check if thread 1 is stopped running, then it updates the UI Have to do.

Now, I know what I want to achieve or other mechanisms, but once I have to face this problem, I need to know that it is better to do Before learning the methods, I am doing what is wrong using this implementation.

The problem is that sometimes it is perfectly executed and at other times the thread only exits the code 0, without informing it to update my UI Updates for

The actual code:

  // call the file manager (Singleton) async file loader method Menvandu CS Class Fmklodframdiaisaiansisi (new director Info (dialogue Selected path)); // This method File Manager singleton class public Wide Lodfromdiaiarsiaiansi (Nirdeshikainf D) {loadFiles = new Thread (() = & gt; full Dairilist (D, "in *. Mp3")); LoadFiles.Start (); LoadFiles.Name = "loadFromDirAsync"; } // return MainWindow class, start a new thread to check if async load thread is still running: // Check whether expires Thread t = new Thread ((=) gt; load (to)) ; T.Start (); T.Name = "LoaderTrade"; // This method checks (in the main window) that the loader thread in the file manager is still alive: private zero load () {when (runCheck) {// If the Async file loading thread is finished ... if (! Fm.isThreadStill Loading ()) {Console.WriteLine ("Running"); Dispatcher.Invoke (System.Windows.Threading.DispatcherPriority.Normal, new Action (delegate () {loadBTN.IsEnabled = true; pb.IsInderminate = false; pb.IsEnabled = false; runCheck = false; pbLabel.Content = string.Format ("{1} Finish indexing {0} files in folder - Ready to play.", Fm.filesCount, fm.foldersCount);}); }}}  


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -