admin on November 1st, 2007
using System.Threading; static void Main() {   bool isFirstInstance;   Mutex mutex =      new Mutex(true, "Global\\" + “App_Name_Here”, out isFirstInstance);   if(isFirstInstance)     Application.Run(new YourAppMainClass());   else     MessageBox.Show("There is already an instance running.",         "Warning",         MessageBoxButtons.OK, MessageBoxIcon.Exclamation,         MessageBoxDefaultButton.Buttonx); }

admin on November 1st, 2007
using System.Diagnostics; public void WriteEventLog(string appName, string logDetail) {  if (!System.Diagnostics.EventLog.SourceExists(appName))   System.Diagnostics.EventLog.CreateEventSource(appName,"Application");   EventLog EventLog1 = new EventLog();   EventLog1.Source = appName;   EventLog1.WriteEntry (logDetail, EventLogEntryType.Error); }