Baka_MPlayer.Forms.VoiceForm.Dispose C# (CSharp) Méthode

Dispose() protected méthode

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
Résultat void
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

Usage Example

        private void EnableVoiceCommand()
        {
            try
            {
                if (IsVoiceCommandEnabled) return;

                // if call name isn't set, ask for one
                if (string.IsNullOrEmpty(Properties.Settings.Default.CallName.Trim()))
                {
                    var voiceForm = new VoiceForm();
                    if (voiceForm.ShowDialog() == DialogResult.OK)
                    {
                        if (voiceForm.GetName != Properties.Settings.Default.CallName)
                        {
                            Properties.Settings.Default.CallName = voiceForm.GetName;
                            Properties.Settings.Default.Save();

                            // if voice command is running, restart it
                            if (voice != null)
                            {
                                IsVoiceCommandEnabled = false;
                                voice.SpeechRecognizedEvent += voice_SpeechRecognizedEvent;
                                voice.AudioLevelUpdatedEvent += voice_AudioLevelUpdatedEvent;
                                voice.Dispose();
                                voice = null;
                            }
                            SetStatusMsg("Voice Command: Name changed to " + Properties.Settings.Default.CallName, true);
                        }
                    }
                    voiceForm.Dispose();
                }

                if (voice == null)
                {
                    voice = new VoiceCommandEngine(Properties.Settings.Default.CallName);
                    voice.SpeechRecognizedEvent += voice_SpeechRecognizedEvent;
                    voice.AudioLevelUpdatedEvent += voice_AudioLevelUpdatedEvent;
                }
                voice.StartListening();
                speechButton.Image = Properties.Resources.enabled_mic;
                IsVoiceCommandEnabled = true;
            }
            catch (Exception)
            {
                MessageBox.Show(
                    "There was a problem while starting voice command.\nPlease make sure your mic is plugged in.",
                    "Voice Command", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                speechButton.Image = Properties.Resources.disabled_mic;

                if (voice != null)
                    voice.StopListening();
                IsVoiceCommandEnabled = false;
            }
        }
All Usage Examples Of Baka_MPlayer.Forms.VoiceForm::Dispose