>>>>/// <summary> >>>>/// Main Window State Setting >>>>/// </summary> >>>>public System.Windows.WindowState MainWindowState >>>>{ >>>> get { return OCSDApplication.Current.MainWindow.WindowState; } >>>> set { OCSDApplication.Current.MainWindow.WindowState = value; } >>>>} >>>>>>>>
public partial class SomeWindow : Window >>> { >>> public SomeWindow() >>> { >>> InitializeComponent(); >>> >>> BackgroundWorker b = new BackgroundWorker(); >>> b.DoWork += new DoWorkEventHandler(DoWork); >>> b.RunWorkerAsync(); >>> } >>> >>> public void SetMainWindowState(WindowState ws) >>> { >>> Application.Current.MainWindow.WindowState = ws; >>> } >>> >>> public WindowState GetMainWindowState() >>> { >>> return Application.Current.MainWindow.WindowState; >>> } >>> >>> void DoWork(object sender, DoWorkEventArgs e) >>> { >>> MainWindowState = WindowState.Maximized; >>> WindowState test = MainWindowState; >>> } >>> >>> private WindowState mainWindowState; >>> public WindowState MainWindowState >>> { >>> set { Dispatcher.Invoke(DispatcherPriority.Normal, new Action<WindowState>(SetMainWindowState), value); } >>> get >>> { >>> Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() >>> { mainWindowState = this.GetMainWindowState(); })); >>> return mainWindowState; >>> } >>> } >>> }>>
public static OCSDConfiguration AppConfigurationMgr { get { if (_appConfigurationMgr == null) _appConfigurationMgr = Factory.CreateConfigurationManager(); return _appConfigurationMgr; } set { _appConfigurationMgr = value; } } private static OCSDConfiguration _appConfigurationMgr;Here is the initialize method that gets called from a background worker. I thought background workers were a bit more savy about handling cross thread synchronization. I assume this is the thread that is claiming to own those properties because of this.
internal void Initialize() { var loadedConfig = (OCSDConfiguration)OCSDAppMain.DBUserSettings.GetValue(DBConsts.SETTING_CLIENTCONFIGURATION, "", typeof(OCSDConfiguration)); if (loadedConfig != null) { OCSDMisc.Assign(this, loadedConfig); } }When searching for uses of the MainWindowState I find none. When I do a search for MainWindowState I don't find anything that is touching the setter or getter of the property. I assume then it is in xaml somewhere and have not found it. Regardless of that however it does get touched and must be the UI thread which is touching it. There are other properties in here that will be the same problem, this just happens to be the first to stop it.