Skip to content

Instantly share code, notes, and snippets.

@vcsjones
Created October 31, 2010 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vcsjones/656949 to your computer and use it in GitHub Desktop.
Save vcsjones/656949 to your computer and use it in GitHub Desktop.
using System.Threading;
using System.Windows;
using System.Windows.Threading;
namespace BorderTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public delegate void MyDelegate();
public void dispatchP1()
{
player1.Dispatcher.VerifyAccess();
player1.Dispatcher.Invoke(new MyDelegate(p1SetContent));
}
public void p1SetContent()
{
player1.Content = "WORKS!";
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var thread = new Thread(() => new SecondMainWindow().dispatchP1());
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
}
public class SecondMainWindow : MainWindow
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment