예제 #1
0
 /// <summary>
 /// join a handle
 /// </summary>
 /// <param name="handle"></param>
 /// <returns></returns>
 internal void Add(WaitTableHandle handle)
 {
     lock (this.lockObject)
     {
         this.dictionary.Add(handle.Identity, handle);
     }
 }
예제 #2
0
 /// <summary>
 /// craete a handle
 /// </summary>
 /// <param name="handle"></param>
 /// <returns></returns>
 internal void Remove(WaitTableHandle handle)
 {
     lock (this.lockObject)
     {
         this.dictionary.Remove(handle.Identity);
     }
 }
예제 #3
0
 /// <summary>
 /// get all handles
 /// </summary>
 /// <returns></returns>
 public WaitTableHandle[] GetHandles()
 {
     WaitTableHandle[] handles = null;
     lock (this.lockObject)
     {
         handles = new WaitTableHandle[this.dictionary.Count];
         this.dictionary.Values.CopyTo(handles, 0);
     }
     return(handles);
 }
예제 #4
0
        ///// <summary>
        ///// set a handle
        ///// </summary>
        ///// <param name="identity"></param>
        ///// <returns></returns>
        //public bool Set(long identity)
        //{
        //    var handle = this.GetHandle(identity);
        //    if (handle == null)
        //        return false;

        //    handle.Set();
        //    return true;
        //}

        ///// <summary>
        ///// set a handle
        ///// </summary>
        ///// <param name="identity"></param>
        ///// <param name="userState"></param>
        ///// <returns></returns>
        //public bool Set(long identity, object userState)
        //{
        //    var handle = this.GetHandle(identity);
        //    if (handle == null)
        //        return false;

        //    handle.UserState = userState;
        //    handle.Set();
        //    return true;
        //}

        ///// <summary>
        ///// set a handle
        ///// </summary>
        ///// <param name="identity"></param>
        ///// <param name="userIdentity"></param>
        ///// <returns></returns>
        //public bool Set(long identity, int userIdentity)
        //{
        //    var handle = this.GetHandle(identity);
        //    if (handle == null)
        //        return false;

        //    handle.UserIdentity = userIdentity;
        //    handle.Set();
        //    return true;
        //}

        ///// <summary>
        ///// reset a handle
        ///// </summary>
        ///// <param name="identity"></param>
        ///// <returns></returns>
        //public bool Reset(long identity)
        //{
        //    var handle = this.GetHandle(identity);
        //    if (handle == null)
        //        return false;

        //    handle.Reset();
        //    return true;
        //}

        ///// <summary>
        ///// set a handle user state
        ///// </summary>
        ///// <param name="identity"></param>
        ///// <param name="userState"></param>
        ///// <returns></returns>
        //public bool SetUserState(long identity,object userState)
        //{
        //    var handle = this.GetHandle(identity);
        //    if (handle == null)
        //        return false;

        //    handle.UserState = userState;
        //    return true;
        //}

        /// <summary>
        /// get handle
        /// </summary>
        /// <param name="identity"></param>
        /// <returns></returns>
        public WaitTableHandle GetHandle(long identity)
        {
            WaitTableHandle handle = null;

            lock (this.lockObject)
            {
                this.dictionary.TryGetValue(identity, out handle);
            }
            return(handle);
        }