internal void Complete() { lock (currentResult.Lock) { Execute.OnUIThread(() => currentResult.Callback(currentResult)); currentResult.Complete(); } currentResult = null; }
/// <summary> /// Begins asynchronous loading of the content for the specified target URI. /// </summary> /// <param name="targetUri">The URI to load content for.</param> /// <param name="currentUri">The URI that is currently loaded.</param> /// <param name="userCallback">The method to call when the content finishes loading.</param> /// <param name="asyncState">An object for storing custom state information.</param> /// <returns>An object that stores information about the asynchronous operation.</returns> public IAsyncResult BeginLoad(Uri targetUri, Uri currentUri, AsyncCallback userCallback, object asyncState) { var result = new CaliburnLoaderAsyncResult(asyncState, userCallback) { BeginLoadCompleted = false }; currentResult = result; try { NavigationConductor.NavigateToItem(targetUri); } catch (Exception e) { Error(e, result); } result.BeginLoadCompleted = true; return result; }
/// <summary> /// Ends loading with an error, delaying throwing the error until EndLoad() is called on /// the INavigationContentLoader. /// </summary> /// <param name="error">The error that occurred.</param> /// <param name="result"></param> protected void Error(Exception error, CaliburnLoaderAsyncResult result) { result.Error = error; Complete(); }