CrossThreadRunner.RunInSta C# (CSharp) Method

RunInSta() public method

public RunInSta ( Action userDelegate ) : void
userDelegate Action
return void
    public void RunInSta(Action userDelegate)
    {
        lastException = null;

        var thread = new Thread(() => MultiThreadedWorker(() => userDelegate()));
        thread.SetApartmentState(ApartmentState.STA);

        thread.Start();
        thread.Join();

        if (lastException != null)
        {
            ThrowExceptionPreservingStack(lastException);
        }
    }

Usage Example

 public void LaunchEmpty()
 {
     var runner = new CrossThreadRunner();
     runner.RunInSta(() =>
                         {
                             var configureWindow = new ConfigureWindow(new ConfigureWindowModel());
                             configureWindow.ShowDialog();
                         });
 }
All Usage Examples Of CrossThreadRunner::RunInSta