Issue with updating my UI

前端 未结 1 815
一向
一向 2021-01-15 23:57

I have a Button and use binding to a string (Name property from class Person)

I have the following code:

perso         


        
相关标签:
1条回答
  • 2021-01-16 00:10

    Use ThreadPool like this:

    person1.name = "Name1";
    ThreadPool.QueueUserWorkItem(_ =>
    {
         Thread.Sleep(1000);
    
         Dispatcher.BeginInvoke(new Action(() =>
         {
             person1.name = "Name2";
         }));
    });
    

    Here you can find another post about ThreadPool in more details.

    0 讨论(0)
提交回复
热议问题