RecognizerUpdateReachedEventArgs.UserToken Property

Gets the UserToken passed to the system when an application creates a recognition engine configuration modification request.

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

Syntax

'Declaration
Public ReadOnly Property UserToken As Object
public Object UserToken { get; }
public:
property Object^ UserToken {
    Object^ get ();
}
/** @property */
public Object get_UserToken ()
public function get UserToken () : Object

Property Value

Returns an instance of System.Object containing the UserToken.

Remarks

An application specifies a UserToken by calling the RequestRecognizerUpdate method to request the generation of RecognizerUpdateReached events.

Example

The example below show a handler for RecognizerUpdateReached events which loads or unloads Recognition Grammar objects. The handler uses UserToken to obtain information about the recognizer request, created with RequestRecognizerUpdate ,to verify and implement the request.

//Handle requests for Grammar Loads.
_recognizer.RecognizerUpdateReached +=
   delegate(object s, RecognizerUpdateReachedEventArgs args) {
       GrammarRequest request = args.UserToken as GrammarRequest; //cast and check if incoming type is a request
       if (request != null) { // We know this is a Grammar request now
           if (request.Grammar == null)
               throw new ArgumentException("Invalid grammar used.");
       }
       switch (request.RequestType) {
           case GrammarRequestType.LoadGrammarSync:
               _recognizer.LoadGrammar(request.Grammar);
               break;
           case GrammarRequestType.LoadGrammarAsync:
               _recognizer.LoadGrammarAsync(request.Grammar);
               break;
           case GrammarRequestType.UnloadGrammar:
               _recognizer.UnloadGrammar(request.Grammar);
               break;
       }
   };

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

RecognizerUpdateReachedEventArgs Class
RecognizerUpdateReachedEventArgs Members
Microsoft.Speech.Recognition Namespace
RecognizerUpdateReached
RequestRecognizerUpdate