/// <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; } } } }
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); } }
/// <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); } }
/// <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); }
/// <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); } }
/// <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; } } } }
/// <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; } } } }
/// <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); }
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); } }
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); }
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); }
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); } }
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); } }