Compartir a través de


RecognizerContext.StopBackgroundRecognition Method

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

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Sub StopBackgroundRecognition
'Usage
Dim instance As RecognizerContext

instance.StopBackgroundRecognition
public void StopBackgroundRecognition ()
public:
void StopBackgroundRecognition ()
public void StopBackgroundRecognition ()
public function StopBackgroundRecognition ()
Not applicable.

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.

Example

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;
        }
    }

This Microsoft® Visual Basic® .NET 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

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RecognizerContext Class
RecognizerContext Members
Microsoft.Ink Namespace
Microsoft.Ink.RecognizerContext.BackgroundRecognize
Microsoft.Ink.RecognizerContext.BackgroundRecognizeWithAlternates