Hi I have two applications say "application 1" and "application 2", now my "application 1" continuously read value from config file that is used or defined in it. "application 2" update above config file declare in "application 1".
I have used delegate and event structure where once current value get change subscriber get notification in "application 1"
My main code is given bellow
public class Configcheck
{
public bool ConfigValue;
public delegate void ConfigChangeEventHandler(object configcheck,
ConfigInfoEventArgs ValueInformation);
public event ConfigChangeEventHandler ConfigChange;
public void Run()
{
for (; ; )
{
Thread.Sleep(100);
bool read_configvalue = Convert.ToBoolean(CryptorEngine.Decrypt(ConfigurationManager.AppSettings["CHKEBL"].ToString(), true));
if (read_configvalue != ConfigValue)
{
ConfigInfoEventArgs configInformation =
new ConfigInfoEventArgs(read_configvalue);
if (ConfigChange != null)
{
ConfigChange(this, configInformation);
}
}
this.ConfigValue = read_configvalue;
}
}
}
My problem is that when "application 2" changes the app.config file defined in "application 1", the above for loop does not read the updated value. I need to restart the "application 1" to read the updated value.
so I need "application 1" should read updated value as soon as it get changed by the "application 2". please note that "application 1" and "application 2" run simultaneously.
Value that I want to read from the app.config file is as given bellow.
<appsettings>
<add key="CHKEBL" value="true" />
</appsettings>
Application 2 changes above value to true or false so accordingly that updated value of config file my application 1 should read in real time.
Thanks in Advance.