public static void StartAsynchronously(bool killWindowOnRegionCreation, RegionManagerPage page, IConfigSource config, IRegionManagement regionManagement) { Thread t = new Thread(delegate() { try { RegionManager manager = new RegionManager(killWindowOnRegionCreation, page, config, regionManagement); Application.Run(manager); } catch { } }); t.SetApartmentState(ApartmentState.STA); t.Start(); }
public static void StartSynchronously(bool killWindowOnRegionCreation, RegionManagerPage page, IConfigSource config, IRegionManagement regionManagement) { bool done = false; Thread t = new Thread(delegate() { try { RegionManager manager = new RegionManager(killWindowOnRegionCreation, page, config, regionManagement); Application.Run(manager); done = true; } catch { done = true; } }); t.SetApartmentState(ApartmentState.STA); t.Start(); while (!done) Thread.Sleep(100); }
public static RegionInfo StartSynchronously(bool killWindowOnRegionCreation, RegionManagerPage page, IConfigSource config, IRegionManagement regionManagement, RegionInfo startingRegionInfo) { RegionManager manager = null; bool done = false; Thread t = new Thread(delegate() { try { manager = new RegionManager(killWindowOnRegionCreation, page, config, regionManagement, startingRegionInfo); Application.Run(manager); done = true; } catch { done = true; } }); t.SetApartmentState(ApartmentState.STA); t.Start(); while (!done) Thread.Sleep(100); if (manager.RegionInfo == null) { MessageBox.Show("You did not create a region, try again (if you did, make sure you presed the Update button!)"); return StartSynchronously(killWindowOnRegionCreation, page, config, regionManagement, startingRegionInfo); } return manager.RegionInfo; }