Example #1
0
        public void PlayStart(byte[] source)
        {
            if (this.backgroundWorker != null)
            {
                this.backgroundWorker.Abort();
            }

            this.backgroundWorker                     = new AbortableBackgroundWorker.AbortableBackgroundWorker();
            this.backgroundWorker.DoWork             += this.BackgroundWorker_DoWork;
            this.backgroundWorker.RunWorkerCompleted += (sender1, args) =>
            {
                if (args.Cancelled)
                {
                    if (args.Error != null)
                    {
                        //MessageBox.Show(string.Format("{0}: Long running task failed. Error: {1}", DateTime.Now.TimeOfDay, args.Error));
                    }
                }

                if (this.backgroundWorker != null)
                {
                    this.backgroundWorker.Dispose();
                    this.backgroundWorker = null;
                }
            };

            this.backgroundWorker.WorkerSupportsCancellation = true;
            this.sourceMp3 = source;
            this.backgroundWorker.RunWorkerAsync();
        }
Example #2
0
        public void Dispose()
        {
            if (this.waveOutDevice != null)
            {
                this.waveOutDevice.Stop();
            }

            if (this.waveOutDevice != null)
            {
                this.waveOutDevice.Dispose();
                this.waveOutDevice = null;
            }

            if (this.backgroundWorker != null)
            {
                this.backgroundWorker.Abort();
                if (this.backgroundWorker != null)
                {
                    this.backgroundWorker.Dispose();
                }

                this.backgroundWorker = null;
            }
        }