public partial class Page : UserControl
{
delegate void SetTextCallback(string text);
public Page()
{
InitializeComponent();
TextBlockTest.Text = "5秒钟后变化";
Thread t = new Thread(new ThreadStart(Run));
t.Start();
}
int timer = 5;
private void Run()
{
SetTextCallback call = new SetTextCallback(SetText);
while (timer > 0)
{
timer--;
//call(timer + "秒钟后变化");
this.Dispatcher.BeginInvoke(call, timer + "秒钟后变化");
Thread.Sleep(1000);
}
this.Dispatcher.BeginInvoke(call,"变化结束!");
}
private void SetText(string text)
{
TextBlockTest.Text = text;
}
}
写下从学校走出来后,在北京实习的历程。
努力 加油!