Ejemplo n.º 1
0
 private void CheckNewThread_OnCompleted(CompletedArgs args)
 {
     if (this.IsHandleCreated)
     {
         var meth = new CompletedHandler(CheckNewThread_OnCompleted_UI);
         this.BeginInvoke(meth, new object[] { args });
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Called on a new thread to process events from the graph.  The thread
        /// exits when the graph finishes.
        /// </summary>
        private void EventWait()
        {
            // Returned when GetEvent is called but there are no events
            const int E_ABORT = unchecked ((int)0x80004004);

            int       hr;
            IntPtr    p1, p2;
            EventCode ec;
            EventCode exitCode = 0;

            IMediaEvent pEvent = (IMediaEvent)m_FilterGraph;

            do
            {
                // Read the event
                for (
                    hr = pEvent.GetEvent(out ec, out p1, out p2, 100);
                    hr >= 0;
                    hr = pEvent.GetEvent(out ec, out p1, out p2, 100)
                    )
                {
                    Debug.WriteLine(ec);
                    switch (ec)
                    {
                    // If the clip is finished playing
                    case EventCode.Complete:
                    case EventCode.ErrorAbort:
                    case EventCode.UserAbort:
                        exitCode = ec;

                        // Release any resources the message allocated
                        hr = pEvent.FreeEventParams(ec, p1, p2);
                        DsError.ThrowExceptionForHR(hr);
                        break;

                    default:
                        // Release any resources the message allocated
                        hr = pEvent.FreeEventParams(ec, p1, p2);
                        DsError.ThrowExceptionForHR(hr);
                        break;
                    }
                }

                // If the error that exited the loop wasn't due to running out of events
                if (hr != E_ABORT)
                {
                    DsError.ThrowExceptionForHR(hr);
                }
            } while (exitCode == 0);

            // Send an event saying we are complete
            if (Completed != null)
            {
                CompletedArgs ca = new CompletedArgs(exitCode);
                Completed(this, ca);
            }
        } // Exit the thread
Ejemplo n.º 3
0
 private void Completed(object o, System.EventArgs e)
 {
     CompletedArgs ca = e as CompletedArgs;
     button1.Text = "Doit";
     tbStatus.Text = ca.Result.ToString();
     ds.Dispose();
     ds = null;
     groupBox2.Enabled = true;
     GC.Collect(); GC.WaitForPendingFinalizers();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 当输出视频结束后触发此完成事件
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        private void OutCompleted(object o, System.EventArgs e)
        {
            CompletedArgs ca = e as CompletedArgs;

            PlayState = PlayState.Stop;
            if (des != null)
            {
                des.Dispose();
            }
            des = null;
            GC.Collect(); GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// PlayList播放完后触发此完成事件
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        private void Completed(object o, System.EventArgs e)
        {
            CompletedArgs ca = e as CompletedArgs;

            if (curNum == dsArr.Length)
            {
                PlayState = PlayState.Stop;
            }
            else
            {
                PlayState = PlayState.Next;
            }
            GC.Collect(); GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 6
0
 private void CheckNewThread_OnCompleted_UI(CompletedArgs args)
 {
     if (args != null)
     {
         if (args.IsSuccessd)
         {
             llabDownUrl.Visible = true;
             llabDownUrl.Text    = CommonLib.GetLocalString("about_label_download");
             llabDownUrl.Tag     = args.download_url;
             labLastVersion.Text = CommonLib.GetLocalString("about_label_last_version", args.version);
             MessageBox.Show(args.description);
         }
         else
         {
             labLastVersion.Text = CommonLib.GetLocalString("about_label_last_none");
             MessageBox.Show(args.Message);
         }
     }
 }
Ejemplo n.º 7
0
    //void eventListener_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    //{
    //  this.CloseAudioFile();
    //}

    /// <summary>
    /// Called on a new thread to process events from the graph.  The thread
    /// exits when the graph finishes.  Cancelling is done here.
    /// </summary>
    private void EventWait()
    {
      // Returned when GetEvent is called but there are no events
      const int E_ABORT = unchecked((int)0x80004004);

      int hr;
      IntPtr p1, p2;
      EventCode ec;
      EventCode exitCode = 0;

      IMediaEvent pEvent = (IMediaEvent)this.filterGraph;

      do
      {
        // Read the event
        for (
            hr = pEvent.GetEvent(out ec, out p1, out p2, 100);
            hr >= 0 && this.currentState == PlayState.Running;
            hr = pEvent.GetEvent(out ec, out p1, out p2, 100)
            )
        {
          switch (ec)
          {
            // If all files finished playing
            case EventCode.Complete:
            case EventCode.ErrorAbort:
            case EventCode.UserAbort:
              ChangeState(PlayState.Exiting);
              exitCode = ec;
              break;
          }

          // Release any resources the message allocated
          hr = pEvent.FreeEventParams(ec, p1, p2);
          DsError.ThrowExceptionForHR(hr);

        }

        // If the error that exited the loop wasn't due to running out of events
        if (hr != E_ABORT)
        {
          DsError.ThrowExceptionForHR(hr);
        }
      } while (this.currentState == PlayState.Running);

      // If the user cancelled
      if (this.currentState == PlayState.Cancelling)
      {
        // Stop the graph, send an appropriate exit code
        hr = this.mediaControl.Stop();
        exitCode = EventCode.UserAbort;
      }


      // Send an event saying we are complete
      if (exitCode == EventCode.Complete && Completed != null)
      {
        CompletedArgs ca = new CompletedArgs(exitCode);
        Completed(this, ca);
      }
      //threadCompleted = true;
    } // Exit the thread
Ejemplo n.º 8
0
 protected virtual void OnDownloadCompleted(CompletedArgs completedArgs)
 {
     this.DownloadCompleted?.Invoke(this, completedArgs);
 }
Ejemplo n.º 9
0
 protected virtual void OnUpgradeCompleted(CompletedArgs completedArgs)
 {
     this.UpgradeCompleted?.Invoke(this, completedArgs);
 }
Ejemplo n.º 10
0
        //void eventListener_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        //{
        //  this.CloseAudioFile();
        //}

        /// <summary>
        /// Called on a new thread to process events from the graph.  The thread
        /// exits when the graph finishes.  Cancelling is done here.
        /// </summary>
        private void EventWait()
        {
            // Returned when GetEvent is called but there are no events
            const int E_ABORT = unchecked ((int)0x80004004);

            int       hr;
            IntPtr    p1, p2;
            EventCode ec;
            EventCode exitCode = 0;

            IMediaEvent pEvent = (IMediaEvent)this.filterGraph;

            do
            {
                // Read the event
                for (
                    hr = pEvent.GetEvent(out ec, out p1, out p2, 100);
                    hr >= 0 && this.currentState == PlayState.Running;
                    hr = pEvent.GetEvent(out ec, out p1, out p2, 100)
                    )
                {
                    switch (ec)
                    {
                    // If all files finished playing
                    case EventCode.Complete:
                    case EventCode.ErrorAbort:
                    case EventCode.UserAbort:
                        ChangeState(PlayState.Exiting);
                        exitCode = ec;
                        break;
                    }

                    // Release any resources the message allocated
                    hr = pEvent.FreeEventParams(ec, p1, p2);
                    DsError.ThrowExceptionForHR(hr);
                }

                // If the error that exited the loop wasn't due to running out of events
                if (hr != E_ABORT)
                {
                    DsError.ThrowExceptionForHR(hr);
                }
            } while (this.currentState == PlayState.Running);

            // If the user cancelled
            if (this.currentState == PlayState.Cancelling)
            {
                // Stop the graph, send an appropriate exit code
                hr       = this.mediaControl.Stop();
                exitCode = EventCode.UserAbort;
            }


            // Send an event saying we are complete
            if (exitCode == EventCode.Complete && Completed != null)
            {
                CompletedArgs ca = new CompletedArgs(exitCode);
                Completed(this, ca);
            }
            //threadCompleted = true;
        } // Exit the thread