I have the following code:
private void WatchFileForChanges()
{
if (fileInfo.Directory != null)
{
_watcher = new FileSystemWatcher(fileInfo.Directory.FullName, fileInfo.Name);
_watcher.NotifyFilter = NotifyFilters.LastWrite;
_watcher.Changed += OnFinalBuilderStatusChanged;
_watcher.EnableRaisingEvents = true;
}
}
private void OnChanged(object source, FileSystemEventArgs e)
{
lock (this)
{
// here i see 2 different threads coexist
// even there is a lock!!
DispatchResult();
}
}
as can be sing in the comment, i am seeing to different threads co-exist in the OnChanged even there is a lock mechanism, how come??