C# |
![]() |
class MyApplication { public static void Main() { if ( InstanceExists() ) { return; } Console.WriteLine( “Application is running… Press enter to exit” ); Console.ReadLine(); } static bool InstanceExists() { bool createdNew; Mutex mutex = new Mutex( false, "My Mutex Name", out createdNew ); return createdNew; } } |
![]() |
![]() |
![]() |
![]() |
Form FindOpenForm( string key ) { foreach (Form frm in Application.OpenForms) { foreach (object obj in frm.GetType().GetCustomAttributes(false)) { if (obj is FormKeyAttribute) { FormKeyAttribute fk = obj as FormKeyAttribute; if (fk.Key == FormKeys.VoucherInfo) return frm; } } } return null; } |
![]() |