コード例 #1
0
        /// <summary>
        /// Checks the timeout entrys for any that have expired.
        /// </summary>
        public void CheckTimeouts( )
        {
            lock (List.SyncRoot)
            {
                if (List.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < List.Count; i++)
                {
                    TimeoutEntry toe = List[i] as TimeoutEntry;

                    if (toe == null)
                    {
                        continue;
                    }

                    if (toe.TimeoutTime < DateTime.Now)
                    {
                        m_Parent.ConnectionRequestTimedOut(toe.ServerIP, toe.ServerPort, toe.ConnectionRequestID);
                        List.Remove(toe);
                        return;
                    }
                }
            }
        }
コード例 #2
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public void CheckTimeouts()
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                if (base.List.Count != 0)
                {
                    for (int i = 0; i < base.List.Count; i++)
                    {
                        TimeoutEntry timeoutEntry = base.List[i] as TimeoutEntry;
                        if (timeoutEntry != null && timeoutEntry.TimeoutTime < DateTime.Now)
                        {
                            this.m_Parent.ConnectionRequestTimedOut(timeoutEntry.ServerIP, timeoutEntry.ServerPort, timeoutEntry.ConnectionRequestID);
                            base.List.Remove(timeoutEntry);
                            break;
                        }
                    }
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }
コード例 #3
0
ファイル: ConnTimeout.cs プロジェクト: MonetInfor/MFCToolkit
		/// <summary>
		/// Adds a connection into the timeout list
		/// </summary>
		public void AddConnectionEntry(string IP, int Port, int TimeoutSecs, string RequestID)
		{
			lock(List.SyncRoot)
			{
				//Remove any existing connection attempt to this IP/Port.
				if(EntryExists(IP, Port))
					RemoveConnectionEntry(IP, Port);

				//Create the entry
				TimeoutEntry toe = new TimeoutEntry( );
				toe.ServerIP = IP;
				toe.ServerPort = Port;
				toe.TimeoutTime = DateTime.Now.AddSeconds(TimeoutSecs);
				toe.ConnectionRequestID = RequestID;

				//Add to the list
				List.Add(toe);
			}
		}
コード例 #4
0
        /// <summary>
        /// Returns whether or not a connection reauest exists based on its unique request ID.
        /// </summary>
        public bool EntryExists(string RequestID)
        {
            lock (List.SyncRoot)
            {
                for (int i = 0; i < List.Count; i++)
                {
                    TimeoutEntry toe = List[i] as TimeoutEntry;

                    if (toe == null)
                    {
                        continue;
                    }

                    if (toe.ConnectionRequestID == RequestID)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
        /// <summary>
        /// Adds a connection into the timeout list
        /// </summary>
        public void AddConnectionEntry(string IP, int Port, int TimeoutSecs, string RequestID)
        {
            lock (List.SyncRoot)
            {
                //Remove any existing connection attempt to this IP/Port.
                if (EntryExists(IP, Port))
                {
                    RemoveConnectionEntry(IP, Port);
                }

                //Create the entry
                TimeoutEntry toe = new TimeoutEntry( );
                toe.ServerIP            = IP;
                toe.ServerPort          = Port;
                toe.TimeoutTime         = DateTime.Now.AddSeconds(TimeoutSecs);
                toe.ConnectionRequestID = RequestID;

                //Add to the list
                List.Add(toe);
            }
        }
コード例 #6
0
        /// <summary>
        /// Removes a connection from the timeout list
        /// </summary>
        public void RemoveConnectionEntry(string request_id)
        {
            lock (List.SyncRoot)
            {
                for (int i = 0; i < List.Count; i++)
                {
                    TimeoutEntry toe = List[i] as TimeoutEntry;

                    if (toe == null)
                    {
                        continue;
                    }

                    if (toe.ConnectionRequestID == request_id)
                    {
                        List.Remove(toe);
                        return;
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Removes a connection from the timeout list
        /// </summary>
        public void RemoveConnectionEntry(string IP, int Port)
        {
            lock (List.SyncRoot)
            {
                for (int i = 0; i < List.Count; i++)
                {
                    TimeoutEntry toe = List[i] as TimeoutEntry;

                    if (toe == null)
                    {
                        continue;
                    }

                    if ((toe.ServerIP == IP) && (toe.ServerPort == Port))
                    {
                        List.Remove(toe);
                        return;
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Finds out whether a time out entry exists or not.
        /// </summary>
        public bool EntryExists(string IP, int Port)
        {
            lock (List.SyncRoot)
            {
                for (int i = 0; i < List.Count; i++)
                {
                    TimeoutEntry toe = List[i] as TimeoutEntry;

                    if (toe == null)
                    {
                        continue;
                    }

                    if ((toe.ServerIP == IP) && (toe.ServerPort == Port))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #9
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public void RemoveConnectionEntry(string IP, int Port)
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                for (int i = 0; i < base.List.Count; i++)
                {
                    TimeoutEntry timeoutEntry = base.List[i] as TimeoutEntry;
                    if (timeoutEntry != null && timeoutEntry.ServerIP == IP && timeoutEntry.ServerPort == Port)
                    {
                        base.List.Remove(timeoutEntry);
                        break;
                    }
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }
コード例 #10
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public bool EntryExists(string IP, int Port)
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                for (int i = 0; i < base.List.Count; i++)
                {
                    TimeoutEntry timeoutEntry = base.List[i] as TimeoutEntry;
                    if (timeoutEntry != null && timeoutEntry.ServerIP == IP && timeoutEntry.ServerPort == Port)
                    {
                        return(true);
                    }
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
            return(false);
        }
コード例 #11
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public bool EntryExists(string RequestID)
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                for (int i = 0; i < base.List.Count; i++)
                {
                    TimeoutEntry timeoutEntry = base.List[i] as TimeoutEntry;
                    if (timeoutEntry != null && timeoutEntry.ConnectionRequestID == RequestID)
                    {
                        return(true);
                    }
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
            return(false);
        }
コード例 #12
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public void RemoveConnectionEntry(string request_id)
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                for (int i = 0; i < base.List.Count; i++)
                {
                    TimeoutEntry timeoutEntry = base.List[i] as TimeoutEntry;
                    if (timeoutEntry != null && timeoutEntry.ConnectionRequestID == request_id)
                    {
                        base.List.Remove(timeoutEntry);
                        break;
                    }
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }
コード例 #13
0
ファイル: ConnTimeout.cs プロジェクト: wxytkzc/GitHubCode
        public void AddConnectionEntry(string IP, int Port, int TimeoutSecs, string RequestID)
        {
            object syncRoot;

            Monitor.Enter(syncRoot = base.List.SyncRoot);
            try
            {
                if (this.EntryExists(IP, Port))
                {
                    this.RemoveConnectionEntry(IP, Port);
                }
                TimeoutEntry timeoutEntry = new TimeoutEntry();
                timeoutEntry.ServerIP            = IP;
                timeoutEntry.ServerPort          = Port;
                timeoutEntry.TimeoutTime         = DateTime.Now.AddSeconds((double)TimeoutSecs);
                timeoutEntry.ConnectionRequestID = RequestID;
                base.List.Add(timeoutEntry);
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }