C # service "A netwerk bios command limit reached", why and what is the best solution?

I have a service that opens multiple watchers to view multiple folders. After viewing the folders for a certain period of time, I get "Network command line limit reached."

As I read in here , this is caused by longer requests than allowed.

I believe this is due to the error handling code below, which is caused by an observer error event. This will start a new observer instance by calling the WatchFile method again. I believe that this leads to the fact that the old non-existent observer works and starts a new observer, but I am afraid that stopping the observer will either prevent him from starting it again or stop all instances based on the observer.

Or am I mistaken and the error depends on the number of changes? This will cause 100 files to be dropped at the same time to cause this error.

I thought about stopping and starting the service whenever I run this error, but this will not solve the problem, but just hide it. Is there a better solution?

private static void watcherError(String directory, Boolean intray, ErrorEventArgs e, FileSystemWatcher watcher)
{
    Exception watchException = e.GetException();
    EventLog.WriteEntry("WhiteFileMover", String.Concat("error gedetecteerd, watcher werd herstart  -  ", watchException.Message), EventLogEntryType.Information);
    watcher = new FileSystemWatcher();
    while (!watcher.EnableRaisingEvents)
    {
        try
        {
            // This will throw an error at the
            // watcher.NotifyFilter line if it can't get the path.
            WatchFile(directory, intray);
        }
        catch(Exception exp)
        {
            // Sleep for a bit; otherwise, it takes a bit of
            // processor time
            EventLog.WriteEntry("WhiteFileMover", String.Concat("Failed to restart watcher, retrying in 5 seconds  -  ", exp.Message), EventLogEntryType.Warning);
            System.Threading.Thread.Sleep(5000);
        }
    }
}
0
2

:

watcher = new FileSystemWatcher();

FileSystemWatcher, . . , . , FileSystemWatcher, . . .

+2

Source: https://habr.com/ru/post/1541640/