Aqueduct.Configuration.Loaders.Xml.XmlConfigurationLoader.ValidateFileAndRaiseSettingsChanged C# (CSharp) Method

ValidateFileAndRaiseSettingsChanged() private method

private ValidateFileAndRaiseSettingsChanged ( ) : void
return void
        private void ValidateFileAndRaiseSettingsChanged()
        {
            _logger.LogInfoMessage("NotificationRaised: Updating config");
            if (Monitor.TryEnter(_lock, 100) == false)
                return;

            int retries = 5;
            FileStream stream = null;
            try
            {
                for (int i = 0; i < retries; i++)
                {
                    try
                    {
                        stream = OpenConfigFileForReadWithoutBlocking();
                        break;
                    }
                    catch (Exception ex)
                    {
                        if (retries == 0)
                            _logger.LogError("Error while trying to open file stream to confirm a change has occurred", ex);

                        stream = null;
                        Thread.Sleep(250);
                    }
                }

                if (stream != null)
                {
                    stream.Close();
                    OnSettingsChanged();
                    _logger.LogInfoMessage("Config updated successfully");
                }
            }
            finally
            {
                if (stream != null)
                    stream.Close();

                Monitor.Exit(_lock);
            }
        }