Author Archive

The Using Block

The using block provides proper declaration and dispose of objects that implement IDisposable interface. IDisposable is implemented by managed classes that access unmanaged resources. FileStream is one such classes that accesses IntPtr and SafeFileHandle which are unmanaged handles.

Read more

Linq Filters On Lists

Microsoft .net framework 3.5 introduced the Language Integrated Query (Linq) feature. Linq provides a set of query operators to filter, join and perform other such data related operations on various types datasources such as lists, dictionaries, datasets etc.

In this article we perform a simple filter operation on a collection of data stored in a list using the traditional foreach loop method and the linq method and compare the performance statistics.

Read more

Threading On Multi-Core CPUs

A multi-core processor combines two or more independent cores on a single chip. This multi-core architecture is adopted by most modern processors enabling execution of multiple threads simultaneously.

This article concentrates on how to optimize multithreading on multi-core CPUs.

Read more

File System Watcher And Large File Volumes

File system watcher listens to the file system change notifications and raises events when a directory, or file in a directory, changes. A very useful tool since it notifies exactly at the moment when a file or directory is created, changed or deleted, without having to do polling on that directory. It can watch sub-directories too.

If that wasn’t enough it also provides filters. For instance u just want notifications about text files then you can provide a filter “*.txt”, now event will be raised only for text files.

The Problem

However there is a downside. The file system watcher is not entirely reliable for working with large volumes of files. The reason for this is that there is a fixed buffer allocated to each file system watcher which is used to store the details such as file location for each file that raises an event. However when a large number of files raise an event then this buffer gets full.

Read more