In the following piece of code I have a watcher that look if file has changed and if it has changed I show the changed information on a form but if i use form.Show() for this it freezes but form.showDialog() works fine, what is the difference between these two and how to determine which one to use
private void watcher_Changed(object sender, FileSystemEventArgs e)
{
_watcher.EnableRaisingEvents = false;
try
{
if (_displayPatientInfo != null)
{
_displayPatientInfo.Dispose();
}
GetPatientInfo(e.FullPath);
using (StreamReader sr = new StreamReader(e.FullPath, Encoding.Default))
{
String line;
line = sr.ReadToEnd();
if (line.IndexOf("<IsPatientFixed>") > 0)
{
var value = GetTagValue(line, "<IsPatientFixed>", "</IsPatientFixed>");
if (value == "true" || value == "True")
{
_displayPatientInfo = new frmPatientInfoDisplay();
_displayPatientInfo.SetData(_patientInfo);
_displayPatientInfo.ShowDialog();
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
_watcher.EnableRaisingEvents = true;
}
}