-1

The PhysicalFilesWatcher, which is being used when setting the UsePollingFileWatcher = true in PhysicalFileProvider, has a default polling interval of 4 seconds.

Is it possible to change this interval?

I want to make the interval smaller for integration tests.

5
  • Why? What's the real problem you want to solve? It matters. Polling is used to catch changes that were missed by the actual FileSystemWatcher that receives OS notification events. This can happen if processing is too slow, and there are so many file changes that the watcher's buffer gets full, causing it to discard events before they're processed. It's also necessary when the actual storage doesn't return notifications at all, or is too slow. A remote file share is different from a local disk Commented Jul 10 at 9:03
  • That means you want to manually trigger changes, not change the polling interval. Unless you want to check whether PhysicalFilesWatcher works as advertised on your production storage. If the problem had to do with missing changes you could increase the buffer of the FSW or add exclusion filters. Commented Jul 10 at 9:16
  • The polling interval is an internal field and can't be changed. Changes to files should be detected immediately if you use an FSW anyway, not wait for 4 seconds. If you check the PhysicalFilesWatcher unit tests you'll see a mock FSW is used to generate change events for testing. The PhysicalFileProviderTests files just make changes to the folder. You could also mock the IFileProvider itself instead of trying to modify PhysicalFileProvider Commented Jul 10 at 9:23
  • I need to use a polling watcher as I'm watching on a Windows share from a Linux server. Mocking is not an option. I need the integration test. Commented Jul 10 at 12:04
  • 1
    Update the question and add all that information there. That's a very different question from the original. You can't modify the polling interval, at least not without using reflection to modify the internal static field DefaultPollingInterval. You could copy the code and modify it though, or create a test-specific variant of the provider and watcher that allows changing the interval Commented Jul 10 at 12:39

0

Browse other questions tagged or ask your own question.