Advertisement
cadrell0

NavigationAsyncResult

Jun 16th, 2011
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. /// <summary>
  2.     /// An IAsyncResult to be used with INavigationContentLoaders
  3.     /// </summary>
  4.     public class NavigationAsyncResult : IAsyncResult
  5.     {
  6.  
  7.         /// <summary>
  8.         /// The content of the navigation.
  9.         /// This will be created by BeginLoad and returned by EndLoad
  10.         /// </summary>
  11.         public object Content { get; set; }
  12.  
  13.         /// <summary>
  14.         /// Keeps track of whether or not this operation has been cancelled.
  15.         /// </summary>
  16.         public bool Cancelled { get; set; }
  17.  
  18.         /// <summary>
  19.         /// Marks this Async operation as complete
  20.         /// </summary>
  21.         public void Complete()
  22.         {
  23.             IsCompleted = true;
  24.             (AsyncWaitHandle as AutoResetEvent).Set();
  25.         }
  26.  
  27.         /// <summary>
  28.         /// Tracks an Exception that may have occured during processing.
  29.         /// </summary>
  30.         public Exception Error { get; set; }
  31.  
  32.         /// <summary>
  33.         /// Creates a new NavigationAsyncResult
  34.         /// </summary>
  35.         /// <param name="asyncState">A user-defined object that qualifies or contains information about an asynchronous operation.</param>
  36.         public NavigationAsyncResult(object asyncState)
  37.         {
  38.             AsyncState = asyncState;
  39.             AsyncWaitHandle = new AutoResetEvent(false);
  40.             CompletedSynchronously = false;
  41.             IsCompleted = false;
  42.             Cancelled = false;
  43.         }
  44.  
  45.         #region IAsyncResult Members
  46.         /// <summary>
  47.         /// Gets a user-defined object that qualifies or contains information about an asynchronous operation.
  48.         /// </summary>
  49.         public object AsyncState { get; private set; }
  50.  
  51.         /// <summary>
  52.         /// A wait handle that is used to wait for an asynchronous operation to complete.
  53.         /// </summary>
  54.         public WaitHandle AsyncWaitHandle { get; private set; }
  55.  
  56.         /// <summary>
  57.         /// Gets a value that indicates whether the asynchronous operation completed synchronously.
  58.         /// </summary>
  59.         public bool CompletedSynchronously { get; set; }
  60.  
  61.         /// <summary>
  62.         /// Gets a value that indicates whether the asynchronous operation has completed.
  63.         /// </summary>
  64.         public bool IsCompleted { get; private set; }
  65.  
  66.         #endregion
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement