Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows;
- namespace WpfCrossThread {
- public partial class MainWindow : Window {
- private delegate void EnterTextDelegate();
- public MainWindow() {
- InitializeComponent();
- }
- private void button_Click(object sender, RoutedEventArgs e) {
- var del = new EnterTextDelegate(EnterText);
- del.BeginInvoke(null, null);
- }
- private void EnterText() {
- if (MyTextBox.Dispatcher.CheckAccess()) {
- MyTextBox.Text = "this may make it fail... or will it?";
- } else {
- var del = new EnterTextDelegate(EnterText);
- MyTextBox.Dispatcher.BeginInvoke(del);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement