第一种方法
private void WriteText(string data)
{
this.Dispatcher.BeginInvoke(
delegate
{
textbox1.text=data
}
);
}
第二种方法
void Showimg()
{
while (true)
{
Thread.Sleep(3000);
ThreadPool.QueueUserWorkItem((threadState) =>
{
// Thread.Sleep(500);
Dispatcher.BeginInvoke(() =>
img1.Visibility = Visibility.Collapsed);
Dispatcher.BeginInvoke(() =>
img2.Visibility = Visibility.Collapsed);
Dispatcher.BeginInvoke(() =>
img3.Visibility = Visibility.Collapsed);
Dispatcher.BeginInvoke(() =>
img4.Visibility = Visibility.Collapsed);
Dispatcher.BeginInvoke(() =>
img5.Visibility = Visibility.Collapsed);
});
}
}