Advertisement
GlobalAccessSoftware

Program.cs

Apr 26th, 2019
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.71 KB | None | 0 0
  1.  
  2.  
  3. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  4. // Program.cs For PrintBlaster.PrintForm
  5. // App Rev4 2.3.7.28 20-Jan-2018
  6. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  7. // v2.2.6.27alexandrite 20-Jan-2018
  8. // v3.3.5.47 Ready to go forward w/this.
  9. // v3.2.4.47 04/09 Near Total Concept!
  10. // v3.3.5.49 04/21 Fully Integrated w/PB
  11. // v4.3.5.49 22-Apr-2018 Integrated.
  12. // v4.3.5.50 Brought Data Mechanism.
  13. // Obsoletes mmf2 and mmf3 stuff.
  14. // (c) John P. Edwards 20-May-2018
  15. // v4.5.6.54 name & optional no-path
  16. // v4.7.1.74 25-Sep-2018
  17. // v4.8.1.78 04-Oct " " Major testing &
  18. // tweeking little details, the Devil
  19. // is in the Details. Sweat them!
  20. // v4.9.4.89 24-Nov-2018
  21. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  22.  
  23. using System;
  24. using System.Threading;
  25. //using System.Windows.Forms;
  26.  
  27. // Aliases (shortcuts)
  28. //using PrintBlaster.Properties;
  29. using APP = System.Windows.Forms.Application;
  30.  
  31. using MyCustomLibrary;
  32.  
  33. namespace PrintBlaster
  34. {
  35.   static class Program
  36.   {
  37.     private const string Nm =
  38.       "PrintBlasterProgramMuter";
  39.  
  40.     private static bool _1St;
  41.  
  42.     public static Mutex Muter = new
  43.       Mutex(false, Nm, out _1St);
  44.  
  45.     /// <summary> Main entry point for this app.
  46.     /// </summary>
  47.     [STAThread]
  48.     static void Main()
  49.     {
  50.       if (_1St)
  51.       {
  52.         try
  53.         {
  54.           APP.EnableVisualStyles();
  55.           APP.
  56.             SetCompatibleTextRenderingDefault
  57.               (false);
  58.           APP.Run(new PrintForm1());
  59.         }
  60.         catch (ObjectDisposedException)
  61.         {
  62.           // EyeOut ReTest on 1st instance.
  63.           #region Release version testcode
  64.           // ^ Cannot access a disposed object
  65.           // if it wasn't even Initialized.
  66.           //if (MyToolbox.Testing)
  67.           //  MessageBox.Show(Resources.Err3);
  68.           #endregion
  69.         }
  70.         finally { Muter.Dispose(); }
  71.       }
  72.       else Main2();// secondary instance calling.
  73.     }
  74.  
  75.     // All the rest are second instance only.
  76.     private static void Main2() // ^^^
  77.     {
  78.       try
  79.       { APP.Run(new PrintForm1(
  80.         MyToolbox.GetSavedArgs())); }
  81.       catch (ObjectDisposedException)
  82.       {
  83.         // EyeOut ReTest on 2nd instances.
  84.         #region Release version testcode
  85.         // ^ Cannot access a disposed object
  86.         // if it wasn't even Initialized.
  87.         //if (MyToolbox.Testing)
  88.         //  MessageBox.Show(
  89.         //    string.Format(
  90.         //      "{0} in Blaster Program Main2:\n\n",
  91.         //      "Cannot Dispose of" +
  92.         //      " Disposed Object:\n\n" +
  93.         //      "Msg Shown Only if Testing.\n\n" +
  94.         //      "Error Handled Either Way."));
  95.         #endregion
  96.       }
  97.     }
  98.     //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  99.  
  100.  
  101.   }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement