Free Electronic Book: Programming Windows Phone 7

You can get a free ebook, Programming Windows Phone 7, by Charles Petzold here:


Attaching an Event Handler

Whenever I need to attach an event handler, usually I use one of these methods, a delegate, anonymous method, or lambda expression. For complex events (more than 3 lines of code), I create a separate method. If the method is short, I use anonymous method. But if the event is just one line, I use…


How to Give Authenticated Users or Everyone Access to Your Share Programmatically

Another follow-up from my previous article, Programmatically Configuring Permissions on a Share, David B asked a question, how to share a folder to Everyone, instead of to a specific users. This article will answer that question, based on the code on my previous article. That is an interesting question, since ‘Everyone’ can be replaced with…


How to Programmatically Modify the IIS Virtual Directory

If you have more than a dozen web servers in a cluster with identical setting, and you need to update the virtual directory, it is much more convenient to write a simple program to update it. This example shows how to do it. In this case, this snippet will change the physical path of a…


C# 3.0 Automatic Property

C# introduces a number of syntactic sugar, including Automatic Property link. A question was asked, why is this useful, what is the advantage of this approach compared to exposing the field as public field? The advantage of the automatic property is that while you have a much cleaner code, you still have encapsulation, you can…


Fixing the Issue that Does Not Exist

I spent some time planning on improvements that I wanted to do on one of our project. I reviewed the code that I notice a place where I think I could improve the performance by avoiding locking. So I wrote the code, and tested it, works great, the new non-locking algorithm works fine. Then when…


Writing Fast Code (Resources)

This article is intended to help me remember where can I find these resources, also kind of helpful should I need to forward this to someone. Hopefully, this post will be continuously updated. Managed code is very fast in allocating memory, the problem is if the applications allocated too many unnecessary objects. Keep your memory…


When Building Multi-Threaded Applications using ThreadPool, Make the Number of Worker Threads Configurable

Just a simple thought, when creating a multi-threaded applications, make the number of threads configurable. ThreadPool has this behavior that it will immediately set the minimum worker threads equal to the number of logical processors in your machine, and set the maximum to 250 per logical processor, well documented in msdn (.Net Framework 2.0 SP1)….


String.Split has High Cost on Performance

One application had a memory issue, it just consume too much resources. The application performed well, but it is very obvious when we saw the performance counters, something can be done to make it better. Reviewing the code did not reveal something significant, the code already allocated objects that are necessary. The code parses a…


How to Create Custom Event Log for Windows Service

When you created a Windows Service, you usually add a Service Installer to allow this service to be installed using InstallUtil or installing it programmatically like this post shows you. The service installer will create the Event Log for the service, and by default it is "Application", and the source is the name of your…