private void AddClient(Manager mgr)
 {
     lock(m_clients)
     {
         if(FindClient( mgr ) == null)
         {
             m_clients.Add( new Client(mgr) );
         }
     }
 }
        private void RemoveClient(Manager mgr)
        {
            lock(m_clients)
            {
                int iClient;
                Client client = FindClient( mgr, out iClient );

                if (client != null)
                {                    
                    m_clients.RemoveAt(iClient);
                }
            }
        }
        private Client FindClient(Manager mgr, out int iClient)
        {
            lock (m_clients)
            {
                for (iClient = 0; iClient < m_clients.Count; iClient++)
                {
                    Client client = m_clients[iClient];

                    if ((object)client.m_manager == (object)mgr) return client;
                }
            }

            return null;
        }
        private Client FindClient( Manager mgr )
        {
            int iClient;

            return FindClient( mgr, out iClient );
        }
        public void UnregisterForEvents( Manager mgr )
        {
            Client client = FindClient(mgr);

            if (client != null && client.m_fNotify == true)
            {
                client.m_fNotify = false;

                if (--m_clientsInterestedInEvents == 0)
                {
                    StopEvents();
                }                
            }
        }
        public void RegisterForEvents( Manager mgr )
        {
            Client client = FindClient( mgr );

            if (client != null && client.m_fNotify == false)
            {
                client.m_fNotify = true;

                if (m_clientsInterestedInEvents++ == 0)
                {
                    StartEvents();
                    RefreshDeviceList();
                }
            }
        }
 public void Unregister( Manager mgr )
 {
     UnregisterForEvents( mgr );
     RemoveClient       ( mgr );
 }
 public void Register( Manager mgr )
 {            
     AddClient( mgr );         
 }
 public Client(Manager mgr)
 {
     m_manager = mgr;
 }