In our first example, we are going to manually wrap the Windows FileSystemWatcher object to do what we want. This will give us ultimate control over the object and the process. This work was originally done by Mr. Peter Meinl, and a big thanks goes out to him to allow us to use his work in this book. You can check out his blog at https://petermeinl.wordpress.com/.
Here's what we hope to accomplish in this chapter:
Architecture of classes: Buffering and Recovering FSW
The first class we will provide is the BufferingFileSystemWatcher. This object:
- Buffers FileSystemWatcher events in a BlockingCollection. This helps reduce memory consumption and it even over increases the internal buffer size.
- Reports existing files via a new event, Existed.
- Provides sorting events by oldest (existing) files first. This is the default when subscribing...