public static void Main(string[] args)
 {
     try
        {
     System.Diagnostics.Process[] processes =
      System.Diagnostics.Process.GetProcessesByName("iFolderClient");
     if(processes.Length > 1)
     {
      Debug.PrintLine("iFolder is already running!");
      return;
     }
        }
        catch (Exception)
        {
     Console.WriteLine("\n GetProcessesByName failed to fetch the list of processes");
        }
        try
        {
     application = new iFolderApplication(args);
     application.Run();
        }
        catch(Exception bigException)
        {
     Debug.PrintLine(bigException.Message);
     iFolderCrashDialog cd = new iFolderCrashDialog(bigException);
     if (!Util.RegisterModalWindow(cd))
     {
      try
      {
       Util.CurrentModalWindow.Destroy();
       Util.RegisterModalWindow(cd);
      }
      catch{}
     }
     cd.Run();
     cd.Destroy();
     cd = null;
      application.SimiasManager.Stop();
     Application.Quit();
        }
 }
 public static void Main(string[] args)
 {
     Process[] processes =
     System.Diagnostics.Process.GetProcessesByName("iFolderClient");
        if(processes.Length > 1)
        {
     Console.WriteLine("iFolder is already running!");
     return;
        }
        try
        {
     application = new iFolderApplication(args);
     application.Run();
        }
        catch(Exception bigException)
        {
     Console.WriteLine(bigException);
     iFolderCrashDialog cd = new iFolderCrashDialog(bigException);
     cd.Run();
     cd.Hide();
     cd.Destroy();
     cd = null;
     if(application.EventBroker != null)
      application.EventBroker.Deregister();
     Console.Write("iFolderApplication: Inside catch and calling SimiasManager.Stop()...");
     application.SimiasManager.Stop();
     Console.WriteLine("\tdone calling SimiasManager.Stop()");
     Application.Quit();
        }
 }