Program.cs (1176B)
1 // BSD 3-Clause License 2 // Copyright(c) 2018-2020 René Wagner 3 // https://git.sr.ht/~rwa/worktimehero 4 5 using System; 6 using System.Collections.Generic; 7 using System.Linq; 8 using System.Threading; 9 using System.Threading.Tasks; 10 using System.Windows.Forms; 11 12 namespace WorkTimeHero 13 { 14 static class Program 15 { 16 /// <summary> 17 /// The main entry point for the application. 18 /// </summary> 19 [STAThread] 20 static void Main() 21 { 22 Mutex mut = new Mutex(true, "WorkTimeHero", out bool createdNew); 23 try 24 { 25 if ( createdNew ) 26 { 27 Application.EnableVisualStyles(); 28 Application.SetCompatibleTextRenderingDefault( false ); 29 Application.Run( new MainForm() ); 30 31 // Release the Mutex. 32 mut.ReleaseMutex(); 33 } 34 else 35 { 36 MessageBox.Show("Programm läuft schon", "WorkTimeHero"); 37 } 38 } 39 catch ( Exception ex ) 40 { 41 MessageBox.Show( ex.ToString() ); 42 } 43 finally 44 { 45 // Mutex schließen 46 if ( mut != null ) 47 { 48 if ( createdNew ) 49 { 50 mut.Close(); 51 } 52 } 53 } 54 } 55 } 56 }