コード例 #1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (!(obj is AsyncToken <T>))
            {
                return(false);
            }

            AsyncToken <T> t = (AsyncToken <T>)obj;

            return(t.Token.Equals(this.Token));
        }
コード例 #2
0
        /// <summary>
        /// Waits the specified token and with the specified state data.
        /// </summary>
        /// <param name="token">The asynchronous token.</param>
        /// <param name="state">The user defined state data.</param>
        public void Wait(AsyncToken <TToken> token, TState state)
        {
            lock (syncRoot)
            {
                if (waiter.ContainsKey(token))
                {
                    throw new InvalidProgramException("Invalid async token, the same key already exists.");
                }

                waiter[token] = state;
            }
        }
コード例 #3
0
        /// <summary>
        /// Peeks the specified asynchronous token.
        /// </summary>
        /// <param name="token">The asynchronous token.</param>
        /// <returns>The user defined state data.</returns>
        public TState Peek(AsyncToken <TToken> token)
        {
            lock (syncRoot)
            {
                if (!waiter.ContainsKey(token))
                {
                    throw new AsyncTokenNotFoundException <TToken>(token);
                }

                TState state = waiter[token];
                return(state);
            }
        }
コード例 #4
0
 /// <summary>
 /// The async token can not be found.
 /// </summary>
 /// <param name="token">Async Token</param>
 /// <param name="innerException">Inner exception.</param>
 public AsyncTokenNotFoundException(AsyncToken <TToken> token, Exception innerException)
     : this("Async token is not found.", innerException)
 {
     this.Token = token;
 }