/// <summary> /// Callback for the networkscanner to signal the end /// of the scan process. /// </summary> /// <param name="result">The result is a new host list.</param> public void NetworkScanStateCallback( IAsyncResult result ) { // Check if we are running in the worker thread // If yes, we cannot access the list view. if( this.InvokeRequired ) { // We are, so marshall this call try{ Delegate myDelegate = new UpdateHostlist(NetworkScanStateCallback); this.Invoke( myDelegate, result ); } catch( Exception ex ) { MOE.Logger.DoLog("NetworkScanStateCallback(): " + ex.ToString(), Logger.LogLevel.lvlDebug); } } else { if( m_NetworkScanner != null ) lblStatus.Text = String.Format( MOE.Utility.GetStringFromRes("strNetworkScanProgress"), m_NetworkScanner.GetScanState() ); } }
/// <summary> /// Callback for the networkscanner to signal the end /// of the scan process. /// </summary> /// <param name="result">The result is a new host list.</param> public void NetworkScanFinished( IAsyncResult result ) { // Check if we are running in the worker thread // If yes, we cannot access the list view. if( this.InvokeRequired ) { // We are, so marshall this call Delegate myDelegate = new UpdateHostlist( NetworkScanFinished ); this.Invoke( myDelegate, result ); } else { int iCount = 0; if (m_NetworkScanner == null) return; Monitor.Enter( m_LockHosts ); bool bChanged = false; foreach( WOL2Host h in m_NetworkScanner.Hosts ) { // Check if this host already exists WOL2Host foundHost = null; if (!m_Hosts.Exists(delegate(WOL2Host theHost) { foundHost = theHost; return h.Equals(theHost); })) { if( h != null ) { m_Hosts.Add( h ); bChanged = true; iCount++; } } else { if (foundHost != null) { MOE.Logger.DoLog("NetworkScanFinished: Updating host " + foundHost + "...", MOE.Logger.LogLevel.lvlInfo); // If so, update it. foundHost.SetIpAddress(h.GetIpAddress()); foundHost.SetIpV6Address(h.GetIpV6Address()); foundHost.SetSubnetMask(h.GetSubnetMask()); foundHost.SetMacAddress(h.GetMacAddress()); foundHost.SetName(h.GetName()); MOE.Logger.DoLog("NetworkScanFinished: Updated host " + foundHost, MOE.Logger.LogLevel.lvlInfo); bChanged = true; } } } Monitor.Exit( m_LockHosts ); lblStatus.Text = String.Format( MOE.Utility.GetStringFromRes("strNetworkScanFinished"), iCount); m_NetworkScanner = null; RefreshHostList(); if( bChanged ) // Mark the file as changed ChangedHostsFile(); } }