Whenever a Windows Form is closed, you can catch this event by overriding the OnClosing() method. In this method you have the option to do some cleanup before it closes. You can also prevent the Form from closing by cancelling the closing event. That means that you can turn off the ability to exit a Windows Forms application very easily and for some applications that’s just what you want. You probable just want to hide it and let it run in the background.

The only problem is that if the application cannot be closed, then you cannot turn of Windows because it keeps trying to close the enclosable application. That was a problem for the Site Monitor application, so I started reading the MSDN documentation for a way to fix this issue.

What I found was a new method called OnFormClosing() that is new to the .NET Framework 2.0. I also found that OnClosing() has been deprecated but the Intellisense in Visual Studio didn’t show that. The OnFormClosing() tells you whether it was the user who closed it or if Windows are shutting down or some other reason.

protected override void OnFormClosing(FormClosingEventArgs e)

{

  if (e.CloseReason == CloseReason.UserClosing)

  {

    e.Cancel = true;

    DoSomething();

  }

}

>

So remember to catch the right event and make sure Windows is able to shut down properly.

For quite a while now, I have needed a simple website monitoring tool that would check the uptime of my websites. There are a lot of different ones on the Internet, some are free and some are very expensive. All the ones I found share the same complexity and that doesn’t work for me. So after browsing the web for a while to find a suitable tool I gave up empty handed. I had to write the tool my self.

This is what I wanted

  • Automatic start-up
  • Multi website support
  • Check both HTTP status and title tag
  • Balloon tip notifications
  • Systray application
  • Install and forget
  • Low impact and high performance

This is what I didn’t need

  • E-mail notifications
  • History feature
  • Server installation

The end result is this very simple but very powerful application that does nothing more than it is supposed to do.

It checks websites quietly in the background and pops a balloon tip if a site doesn’t return HTTP status “200 - OK”.

The reason why I chose not to include a history and email/SMS notification feature is because those features are not useful if you sit in front of your computer all day. Then a simple balloon notification would be much less obstrusive. If I’m not in front of my computer I can’t fix any issues on the websites anyway and I don’t want messages on my phone in the weekend.

Download

Site Monitor installer (398 KB)
C# source code (39 KB)