다른 Question에서 나는 익명의 대표자를 사용하는 것에 대한 팁을 얻었다. 기능은 단일 관찰자에 대해 작동하지만 3을 만들면 마지막 관찰자 만 유지됩니다. 익명의 대리인 때문에이 문제가 해결 되었습니까?익명의 위임자를 사용하여 콘솔 응용 프로그램에서 여러 명의 관찰자를 만들 수 있습니까?
코드를 추가했습니다.
foreach (ConfigurationSectionGroup sectionGroup in sectionGroups)
{
if (sectionGroup.Name == "FileCheckerConfigGroup")
{
foreach(ConfigurationSection configurationSection in sectionGroup.Sections)
{
//FileChecker filecheck = new FileChecker();
//filecheck.ProccessFolders(configurationSection);
//FileChecker filecheck = new FileChecker();
var section = ConfigurationManager.GetSection(configurationSection.SectionInformation.SectionName) as NameValueCollection;
watcher = new FileSystemWatcher(section["inputDirectory"]);
watcher.EnableRaisingEvents = true;
watcher.Created += (sender, e) =>
{
using (var filecheck = new FileChecker())
{
filecheck.ProccessFolders(configurationSection);
}
};
}
}
}
이것은 intresting 블로그입니다. 이 하나를 내게 알려 주셔서 감사합니다. – Andy