- string pt = Application.ExecutablePath.Replace("\\", "/") + "/" + Application.ProductName;
- using (Mutex mt = new Mutex(false, pt))
- {
- if (!mt.WaitOne(0, false))
- {
- var text = string.Format(MyCommon.ReplaceAppName(Properties.Resources.StartupText1), MyCommon.GetAssemblyName());
- MessageBox.Show(text, MyCommon.ReplaceAppName(Properties.Resources.StartupText2), MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- ShowPreviousWindow();
- return 1;
- }
-
- TaskScheduler.UnobservedTaskException += (s, e) =>
- {
- e.SetObserved();
- OnUnhandledException(e.Exception.Flatten());
- };
- Application.ThreadException += (s, e) => OnUnhandledException(e.Exception);
- AppDomain.CurrentDomain.UnhandledException += (s, e) => OnUnhandledException((Exception)e.ExceptionObject);
-
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new TweenMain());
-
- mt.ReleaseMutex();
-
- return 0;
- }
- }