Example #1
0
        public Form1()
        {
            if (!PlayerClient.IsServerRunning(22613))
            {
                MessageBox.Show(
                    caption: "TomiSoft MP3 Player",
                    text: "A TomiSoft MP3 Player nem fut.",
                    buttons: MessageBoxButtons.OK,
                    icon: MessageBoxIcon.Error
                    );

                Environment.Exit(0);
            }

            InitializeComponent();
            Client = new PlayerClient(22613);
            Client.KeepAlive();

            this.DoubleBuffered = true;

            this.Timer = new Timer()
            {
                Enabled  = true,
                Interval = 25
            };

            this.Timer.Tick += (o, e) => {
                this.GetNextPeak();
                this.Invalidate();
            };
        }
Example #2
0
        /// <summary>
        /// Checks if an instance of the application is already running. If yes,
        /// sends the command line arguments to it and then terminates this
        /// instance.
        /// </summary>
        private static void CheckIfAlreadyRunning()
        {
            //If an instance is already running, send the file list to it.
            //Otherwise, this is the only running instance, so we start a server to
            //listen to the other instances.
            Trace.TraceInformation("[Player startup] Checking if an instance is already running...");

            if (PlayerClient.IsServerRunning(App.Config.ServerPort))
            {
                Trace.TraceInformation("[Player startup] Found a running instance");
                SendFileListToServer();
                Environment.Exit(0);
            }
            else
            {
                Trace.TraceInformation("[Player startup] No other instances are running.");
            }
        }