次の方法で共有


RecognizerContext.StopBackgroundRecognition Method

RecognizerContext.StopBackgroundRecognition Method

Ends background recognition that was started with a call to BackgroundRecognize or BackgroundRecognizeWithAlternates.

Definition

Visual Basic .NET Public Sub StopBackgroundRecognition()
C# public void StopBackgroundRecognition();
Managed C++ public: void StopBackgroundRecognition();

Exceptions

ObjectDisposedException Leave Site: The RecognizerContext object is disposed.

Remarks

No event is fired when you call the StopBackgroundRecognition method.

Call the StopBackgroundRecognition method if you call BackgroundRecognize or BackgroundRecognizeWithAlternates one or more times. Calling StopBackgroundRecognition does not necessarily ensure that you get no results from a recognition process that is currently underway. It only ensures that all previous calls to BackgroundRecognize or BackgroundRecognizeWithAlternates that have not yet been processed are not executed.

Call this method only if you process the ink asynchronously.

Examples

[C#]

This C# example shows an event handler for a button control's Click event, buttonStop_Click, that halts background recognition of the ink in a RecognizerContext object, theRecognizerContext. The background recognition begins in an InkCollector object's Stroke event handler.

// Stroke event handler
    private void Stroke_Event(object sender,
        InkCollectorStrokeEventArgs e)
    {
        // When a new stroke is collected,
        // add it to the recognizer's strokes collection.
        theStrokes.Add(e.Stroke);
        // Tell the context to recognize its strokes.
        theRecognizerContext.BackgroundRecognize();
        isRecognizingInBackground = true;
    }

    private void buttonStop_Click(object sender, System.EventArgs e)
    {
        if (isRecognizingInBackground)
        {
            theRecognizerContext.StopBackgroundRecognition();
            isRecognizingInBackground = false;
        }
    }

[Visual Basic .NET]

This C# example shows an event handler for a button control's Click event, buttonStop_Click, that halts background recognition of the ink in a RecognizerContext object, theRecognizerContext. The background recognition begins in an InkCollector object's Stroke event handler.

Private Sub Stroke_Event(ByVal sender As Object, _
    ByVal e As InkCollectorStrokeEventArgs)
        'When a new stroke is collected, add it to
        'the RecognizerContext's strokes collection
        theStrokes.Add(e.Stroke)
        'Tell the RecognizerContext to recognize
        theRecognizerContext.BackgroundRecognize()
        isRecognizingInBackground = True
    End Sub

    Private Sub ButtonStop_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles ButtonStop.Click
        If isRecognizingInBackground Then
            theRecognizerContext.StopBackgroundRecognition()
            isRecognizingInBackground = False
        End If
    End Sub

See Also