- private void button3_Click(object sender, RoutedEventArgs e)
- {
- Thread thread = new Thread(ChangeText);
- thread.IsBackground = true;
- thread.Start();
- }
- delegate void MyDelegate();
- private void ChangeText()
- {
- if (Dispatcher.Thread != Thread.CurrentThread)
- {
- Dispatcher.Invoke(new MyDelegate(ChangeText));
- }
- else
- {
- txt_num.Text = "嘿嘿";
- }
- }
复制代码 |
|