private void CheckRaiseChangedEvent(string fullPath) { LocalServerDiscoveryFileEventArgs eventArgs = null; lock (m_Lock) { LocalServerDiscoveryFile newItem = null; if (!m_DiscoveryFiles.ContainsKey(fullPath)) { //we don't actually process change events, only adds. try { newItem = new LocalServerDiscoveryFile(fullPath); if (newItem.IsAlive) { m_DiscoveryFiles.Add(fullPath, newItem); } } catch (Exception ex) { if (!Log.SilentMode) { Log.Write(LogMessageSeverity.Information, NetworkMessenger.LogCategory, "Unable to load local server discovery file due to " + ex.GetType() + " exception", "While attempting to load a local server discovery file an exception was thrown. If this is because the file wasn't found " + "or was incomplete it can be ignored. An incomplete file will raise another event when complete that will cause it to be re-processed.\r\n" + "File: {0}\r\nException: {1}", fullPath, ex.Message); } } if (newItem != null) { eventArgs = new LocalServerDiscoveryFileEventArgs(newItem); } } } //raise the event outside of our lock if (eventArgs != null) { OnFileChanged(eventArgs); } }
/// <summary> /// Create a new event argument /// </summary> /// <param name="file"></param> public LocalServerDiscoveryFileEventArgs(LocalServerDiscoveryFile file) { File = file; }