Compartir a través de


Threading Considerations for the StylusInput APIs

Threading Considerations for the StylusInput APIs

Overview of threading considerations when using the StylusInput application programming interfaces (APIs).

The RealTimeStylus object is designed to provide real-time access to the tablet pen's data stream and runs on its own thread. Synchronous plug-ins generally run on the RealTimeStylus object's thread, while asynchronous plug-ins generally run on the application's user interface (UI) thread. Create or use synchronous plug-ins for tasks that require real-time access to the data stream and are computationally undemanding, such as dynamic rendering. Create or use asynchronous plug-ins for tasks that do not require real-time access to the data stream, such as ink collection.

The following IStylusSyncPlugin methods may run on a thread other than the RealTimeStylus object's thread.

To interact with your application from a synchronous plug-in, use the AddCustomStylusDataToQueue method of the RealTimeStylus object and handle the custom stylus data in one of your asynchronous plug-ins. If you make a synchronous call to another thread from a synchronous plug-in, you may block the RealTimeStylus object and thus block ink collection.

Certain tasks may be computationally demanding yet still require real-time access to the tablet pen's data stream, such as for multistroke gesture recognition. The StylusInput APIs provide a cascaded RealTimeStylus model that allows you to use two RealTimeStylus objects, each running on its own thread. For more information about the cascaded RealTimeStylus model, see The Cascaded RealTimeStylus Model.

Note: You cannot attach the RealTimeStylus object to a window or control in a different application domain.