private static void OnRenamed(object source, RenamedEventArgs e) { try { hostsWatcher.EnableRaisingEvents = false; Thread.Sleep(2000); //nötig um sicher zu stellen, dass schreibende Zugriff abgeschlossen ist InstallBlockList.Blocker(Service1.hostsFile, Service1.newHostsFile); } finally { hostsWatcher.EnableRaisingEvents = true; } }
protected override void OnStart(string[] args) { InstallBlockList.Blocker(hostsFile, newHostsFile); FileWatcher.CreateFileWatcher(hostsFile); }