Exemplo n.º 1
0
        private void StopRunningProcesses()
        {
            try
            {
                if (m_VideoProcess != null)
                {
                    m_VideoProcess.WriteStandardInput("q\n");
                    Thread.Sleep(200);
                }
            }
            catch { }

            try
            {
                if (m_VideoProcess != null)
                {
                    m_VideoProcess.StopRunningProcess();
                }
            }
            catch { }

            m_VideoProcess = null;

            try
            {
                if (m_AudioProcess != null)
                {
                    m_AudioProcess.WriteStandardInput("q\n");
                    Thread.Sleep(200);
                }
            }
            catch { }

            try
            {
                if (m_AudioProcess != null)
                {
                    m_AudioProcess.StopRunningProcess();
                }
            }
            catch { }

            m_AudioProcess = null;
        }
Exemplo n.º 2
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (!btnStop.Enabled)
            {
                return;
            }

            btnStop.Enabled = false;

            if (ckbAutoRestart.Enabled)
            {
                ckbAutoRestart.Checked = false;
            }

            if (m_VideoProcess != null)
            {
                m_VideoProcess.WriteStandardInput("q\n");
                //Thread.Sleep(500);
            }

            if (m_AudioProcess != null)
            {
                m_AudioProcess.WriteStandardInput("q\n");
                //Thread.Sleep(500);
            }

            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(500);
            })
            .ContinueWith((x) =>
            {
                if ((m_VideoProcess != null && !m_VideoProcess.HasExited()) ||
                    (m_AudioProcess != null && !m_AudioProcess.HasExited()))
                {
                    StopRunningProcesses();

                    Task.Factory.StartNew(() =>
                    {
                        Thread.Sleep(500);
                    })
                    .ContinueWith((y) =>
                    {
                        BeginInvoke((Action)(() =>
                        {
                            if (!m_UpdatedUI4Start)
                            {
                                m_UpdatedUI4Start = true;
                                gbMediaSource.Enabled = true;
                                gbVideoTask.Enabled = true;
                                gbAudioTask.Enabled = true;
                                btnStart.Enabled = true;

                                notifyIconMain.Icon = notifyIconStop.Icon;
                                notifyIconMain.Text = this.Text + " (" + notifyIconStop.Text + ")";
                            }
                        }));
                    });
                }
                else
                {
                    BeginInvoke((Action)(() =>
                    {
                        if (!m_UpdatedUI4Start)
                        {
                            m_UpdatedUI4Start = true;
                            gbMediaSource.Enabled = true;
                            gbVideoTask.Enabled = true;
                            gbAudioTask.Enabled = true;
                            btnStart.Enabled = true;

                            notifyIconMain.Icon = notifyIconStop.Icon;
                            notifyIconMain.Text = this.Text + " (" + notifyIconStop.Text + ")";
                        }
                    }));
                }
            });

            btnStop.Enabled = true;
        }