Social Icons

Pages

Change WPF window label content from another class and separate thread




7 comments:

  1. Thanks for the post. It helped me a great deal. I had to do little modification to work for me. If i dont mark it as background activity, until the thread is returned to original thread, it will not update. for example, in this case i had to update the text in background several times while i am making progress..

    ==== In the mainWindow.xaml.cs ======
    set { Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { status_lable.Content = value; })); }

    ==== from my SignIn.cs ======
    MainWindow.main.Status = "Irantha has signed in successfully-1";
    Thread.sleep(2000);

    MainWindow.main.Status = "Irantha has signed in successfully-2";
    Thread.sleep(2000);

    MainWindow.main.Status = "Irantha has signed in successfully-3";
    Thread.sleep(2000);

    MainWindow.main.Status = "Irantha has signed in successfully-4";
    Thread.sleep(2000);

    ReplyDelete
  2. This just literary saved my day.
    Thank you, thank you, and thank you!

    ReplyDelete
  3. It is fantastic: I even cannot understand Your code, however, it works for me fine. Thank you very much!!

    ReplyDelete
  4. Hey , if there is a continuous update from a different async thread then sometimes it is not working as expected , please suggest some other method

    ReplyDelete