Matthieu MEZIL - FileSystemWatcher, Rx and Throttle
"Imagine that we want to be notified if a directory files changed.
In general, when we use files, we don’t need to have a real time application.
Moreover, if we change many files in same time, we perhaps don’t need to have many notification and one notification at the end could be enough.
For this case, Rx and particularly Throttle method is very useful.
...
Now we can use the observable like this:
var fileWatcher = new FileWatcher(".", "*.*", TimeSpan.FromSeconds(5));
var fileObserver = fileWatcher.GetObservable().Subscribe(fce => { /*TODO*/ });Imagine that if we have n changes on the directory in less than 5 seconds between two consecutive changes.
With this code, we have one only notification, 5 seconds after the last one.
Most of the time I hear Rx being mentioned for use in high volume cases like stocks, high event loads, stuff that the normal dev might not see very often. And so the normal dev might think they can ignore Rx.
This is a great example that the normal dev should be able to easily grok and easily see the value that Rx can provide them...
No comments:
Post a Comment
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...