I have a Button
and use binding to a string ( Name
property from class Person
)
I have the following code:
person1.name = "Name1";
Thread.Sleep(1000);
person1.name = "Name2";
With Binding I only see: Name2
after runtime.
I want to see Name1
then after 1 second see Name2
!
How can I realize this? Whats the best method for this?
I also want to use the MVVM - Pattern if this is important.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.