Wednesday, October 29, 2008

How Grownups Debug Windows Service Startups


using System.ServiceProcess;

namespace MyService {

public partial class MyService : ServiceBase {

public MyService() {
InitializeComponent();
}

protected override void OnStart(string[] args) {

//This will launch a debugger
System.Diagnostics.Debugger.Launch();

//Do the real job
MyWorker.Start();
}
}
}

Perpetuating a Meme

So I was checking out Eric Evans' Blog today and I saw a post where he perpetuated this "Random CD Cover Creation" meme. Looked fun and easy.

So Here's Mine (The band's name is Denim not Mined I was just trying to be arty and cool and stuff):



... and Here's the Meme:

1. Use Wikipedia's random article page to find your band name.
2. Go to the Random Quotations Page. The last four words of the very last quote is your album name.
3. Visit Flickr's interesting photos page, the third image, no matter what, is your cover art.

Thursday, October 16, 2008

In a Nutshell, The Difference between an Event and a Delegate

An event simply adds a layer of protection over a delegate instance.

This protection prevents clients of the delegate from resetting the delegate and its invocation list, and only allows adding or removing targets from the invocation list.

Source: http://weblogs.asp.net/rosherove/archive/2004/03/28/100444.aspx

An esteemed colleague directed me to a post (can't recall) that further elaborates on the distinction. The main one that I remember is that in addition to the = restriction, invocations of an Event are restricted to the class that owns the event.

So if you want to allow other classes to raise an event you must expose a public method to that delegates the raising.

C# Sucks!

JK!! Seriously, though, somewhere around C#-3 we should have inculcated ourselves with the question: "Does 'CAN' == 'SHOULD...