SpeechRecognitionEngine.RecognizeAsyncStop Method

Terminates a running instance of a recognition engine after the current recognition operation to completes.

Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)

Syntax

'Declaration

Remarks

When RecognizeAsyncCancel is called, the current asynchrous recognition operation is allowed to complete. All work will be saved and a RecognizeComplete event will be generated.

RecognizeAsyncCancel can be called an asynchronous operation is on going. The operation could have been initialized by calling RecognizeAsync or RecognizeAsynceech.Recognition.RecognizeMode) with either mode

Example

In the following example show the implementation of a start/stop button for a application with a graphical user interface using SpeechRecognitionEngine. Depending on the state of the application, when the button is clicked either RecognizeAsyncCancel or RecognizeAsyncStop is called with the stop state is selected by the user.

private void _startRecogButton_Click(object sender, EventArgs eventArgs) {
    if (_startRecogButton.Text == "Start Speech Recognition") { //Toggle Speech Recogniztion on
        _startRecogButton.Text = "Stop Speech Recognition";
        if (_useMultiple) {
            _recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
        } else {
            _recognitionEngine.RecognizeAsync(RecognizeMode.Single);
        }
    } else {                                                      //Toggle Speech Recognition off
        _startRecogButton.Text = "Start Speech Recognition";
        if (_friendlyStop) {
            _recognitionEngine.RecognizeAsyncStop(); //Stop after current phrase is finished.
        } else {
            _recognitionEngine.RecognizeAsyncCancel(); //Stop before current phrase is finished.
        }

    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

SpeechRecognitionEngine Class
SpeechRecognitionEngine Members
Microsoft.Speech.Recognition Namespace