public void ConnectionThreadFunction() { Console.WriteLine("Thread is running."); while(m_bIsActive) { Thread.Sleep(30000); //sleep for half minute ConnectionChechMessage msg = new ConnectionChechMessage(-1,DateTime.Now.ToFileTime()); //for(int i=0;i<this.ClientList.Count;i++) try { foreach (ClientProfile p in ClientList.Values) { //ClientProfile p = (ClientProfile)ClientList[i]; IMessageReceiver iMessageReceiver = (IMessageReceiver) Activator.GetObject(typeof(IMessageReceiver), p.clientURI); if(p.connectionCheckDateTime != 0) { DateTime dTemp = DateTime.FromFileTime(p.connectionCheckDateTime); TimeSpan aSpan ; if(p.connectionCheckRecievedDateTime != 0) aSpan = DateTime.FromFileTime(p.connectionCheckRecievedDateTime).Subtract(dTemp); else aSpan = DateTime.Now.Subtract(dTemp); if(aSpan.TotalMilliseconds > 300 ) //criteria { //slow p.m_ConnectionIndicator = ConnectionIndicator.Red; } else if((aSpan.TotalMilliseconds > 100 ) && (aSpan.TotalMilliseconds < 300)) { p.m_ConnectionIndicator = ConnectionIndicator.Yellow; } else { p.m_ConnectionIndicator = ConnectionIndicator.Green; } SendUserUpdateMessage(p); } p.connectionCheckDateTime = msg.sentTickCount; iMessageReceiver.ReceiveMessage(msg); } } catch(Exception ex) { ex=ex; //ClientList.Remove(p.ClientId); } SendNonLoggedMessage(msg); // send the message to all clients msg = null; } }
public void checkConnectionUrgent(int clientID) { try { ConnectionChechMessage msg = new ConnectionChechMessage(-1,DateTime.Now.ToFileTime()); ClientProfile p = (ClientProfile)ClientList[clientID]; IMessageReceiver iMessageReceiver = (IMessageReceiver) Activator.GetObject(typeof(IMessageReceiver), p.clientURI); SendUserUpdateMessage(p); //iMessageReceiver.ReceiveMessage(msg); SendNonLoggedMessage(msg); // send the message to all clients } catch(Exception ex) { ex=ex; } }