/// <summary> /// Loads the AvalonDockLayout with a background task and makes the result /// available in a private <see cref="_LayoutLoaded"/> field. /// /// The result can later be queried with the <see cref="GetLayoutString"/> method /// which will eiter return the available result of connect to an eventhandler /// The will return the result via <see cref="LayoutLoadedEvent"/> as soon as it /// is available. /// </summary> public async Task LoadLayoutAsync() { try { var result = await LoadAvalonDockLayoutToStringAsync(); await this._LayoutSemaphore.WaitAsync(); try { this._LayoutLoaded = result; // Send an event if event subscriber is available // if MainWindow is already successfull constructed and waiting for Xml Layout LayoutLoadedEvent?.Invoke(this, new LayoutLoadedEventArgs(result)); } finally { this._LayoutSemaphore.Release(); } } catch (Exception exc) { this._LayoutLoaded = new LayoutLoaderResult(null, false, exc); } }
/// <summary> /// Loads the AvalonDockLayout with a background task and makes the result /// available in a private <see cref="_LayoutLoaded"/> field. /// /// The result can later be queried with the <see cref="GetLayoutString"/> method /// which will eiter return the available result of connect to an eventhandler /// The will return the result via <see cref="LayoutLoadedEvent"/> as soon as it /// is available. /// </summary> public void LoadLayout() { try { Task.Factory.StartNew <LayoutLoaderResult>(() => LoadAvalonDockLayoutToString() ).ContinueWith(async r => { await this._LayoutSemaphore.WaitAsync(); try { this._LayoutLoaded = r.Result; // Send an event if event subscriber is available // if MainWindow is already successfull constructed and waiting for Xml Layout LayoutLoadedEvent?.Invoke(this, new LayoutLoadedEventArgs(r.Result)); } finally { this._LayoutSemaphore.Release(); } }); } catch (Exception exc) { this._LayoutLoaded = new LayoutLoaderResult(null, false, exc); } }
/// <summary> /// Class constructor /// </summary> public LayoutLoadedEventArgs(LayoutLoaderResult paramResult) { Result = paramResult; }