/* * Date Sign TaskId Description * ---------- ---- ------- ----------- * 2006-07-31 RMa Generic version of the AsyncCompletedEventArgs should inherit from the non-generic class with same name. * 2006-03-09 MLa Created */ using System; namespace Wayne.Lib { /// /// Generic event result of an asynchronous command. /// public class AsyncCompletedEventArgs : UserTokenEventArgs { #region Fields private bool success; #endregion #region Construction /// /// Construction. /// /// The status of the reservation. /// An optional user token. public AsyncCompletedEventArgs(bool success, object userToken) : base(userToken) { this.success = success; } #endregion #region Debug methods /// /// Presents the class as a string. /// /// public virtual string ToString(string format, IFormatProvider provider) { return System.String.Format(provider, "AsyncCompletedEventArgs(Success={0})", success); } /// /// Presents the class as a string using the specified culture-specific format information. /// /// public virtual string ToString(IFormatProvider provider) { return ToString("", provider); } /// /// Presents the class as a string using a format string. /// /// public virtual string ToString(string format) { return ToString(format, System.Globalization.CultureInfo.InvariantCulture); } /// /// Presents the class as a string using a format string and the specified culture-specific format information. /// /// public override string ToString() { return ToString("", System.Globalization.CultureInfo.InvariantCulture); } #endregion #region Properties /// /// The status of the reservation. /// public bool Success { get { return success; } } #endregion } /// /// Generic event result of an asynchronous command with an additional status property. /// public class AsyncCompletedEventArgs : AsyncCompletedEventArgs { #region Fields private TResult result; #endregion #region Construction /// /// Construction. /// /// The basic status of the command. /// Refined status of the command. /// An optional user token. public AsyncCompletedEventArgs(bool success, TResult result, object userToken) : base(success, userToken) { this.result = result; } #endregion #region Debug methods /// /// Presents the class as a string. /// /// public override string ToString(string format, IFormatProvider provider) { if (result != null) return String.Format(provider, "AsyncCompletedEventArgs<{0}>(Success={1}, {2})", typeof(TResult).Name, Success, result); else return String.Format(provider, "AsyncCompletedEventArgs<{0}>(Success={1}, null)", typeof(TResult).Name, Success); } #endregion #region Properties /// /// Refined status of the command. /// public TResult Result { get { return result; } } #endregion } }