Meeting the needs of your business from a distance

Ensuring a Single Instance of an Application

by Mark Shiffer 4. August 2008 15:46
Most that have been playing this game for a while immediately think Mutex when you want to ensure your application only runs one instance at a time. I recently came across a .NET class that provides a different approach with some added functionality. The class is WindowsFormsApplicationBase. Unfortunately that class is in the Microsoft.VisualBasic.ApplicationServices namespace, so for C# you have to dirty your code with a VB namespace. The class is pretty simple. Just create it and set IsSingleInstance to true. You then have the ability to hook to events for OnStartupNextInstance, OnShutdown, OnCreateSplashScreen, etc... Worth checking out if you have this need.

Tags: , ,

Research | Programming

Comments

Add comment


(Will show your Gravatar icon)

  Country flag


  • Comment
  • Preview
Loading



Copyright © 2001-2012 MS Consulting, Inc. All Rights Reserved.