Korero – Rev 3

Subversion Repositories:
Rev:
using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace Korero
{
    internal class Program : IDisposable
    {
        #region Static Fields and Constants

        private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid);

        private static Form _form;

        #endregion

        #region Constructors, Destructors and Finalizers

        public void Dispose()
        {
            _form?.Dispose();
            _form = null;
        }

        #endregion

        #region Private Methods

        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            if (Mutex.WaitOne(TimeSpan.Zero, true))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                _form = new MainForm(Mutex);
                Application.Run();
                Mutex.ReleaseMutex();
                return;
            }

            // Foreground current other application window.
            Natives.PostMessage(
                (IntPtr) Natives.HWND_BROADCAST,
                Natives.WM_SHOWME,
                IntPtr.Zero,
                IntPtr.Zero);
        }

        #endregion
    }
}

Generated by GNU Enscript 1.6.5.90.