Share via


General Threading Considerations

General Threading Considerations

Overview of general threading considerations.

The following are general threading considerations when developing for Tablet PC.

Application and Non-Application Threads

All ink events are generated on a separate, high-priority ink thread. This allows ink to flow smoothly even when an application is running slowly. However, event handlers can slow down or block the rendering of ink.

All recognition events generated by background recognition method calls are handled on a separate, normal-priority background recognition thread.

All mouse events are generated on the application's main user interface (UI) thread.

Performance Considerations

Event Handlers

The Tablet PC Platform application programming interface (API) has an interactive model for events rather than a notification model. Keep code in event handlers short to reduce the time that ink rendering is blocked. The collection of ink by the Tablet PC is not blocked, but your application does not receive the ink while your application is blocked.

AutoRedraw Property

When your application is performing custom rendering or when your application is sensitive to painting issues, you can handle the repainting yourself and set the AutoRedraw property to false for the InkCollector object, the InkOverlay object, or the InkPicture control. Use the events in the following table to handle the repainting.

Object or Control Event
InkCollector Object The underlying control's Invalidated Leave Site and Paint Leave Site events.
InkOverlay Object The underlying control's Invalidated Leave Site and Paint Leave Site events.
InkPicture Control InkPicture control's inherited Invalidated Leave Site and Paint Leave Site events.

DynamicRendering Property

When your application is performing custom rendering or when you want the information, but not the ink, you can handle the laying down of ink yourself and turn off real-time rendering of ink by setting the DynamicRendering property to false for the InkCollector object, the InkOverlay object, or the InkPicture control.

Event Threading Considerations

Tablet PC Platform API events are raised on various threads.

InkCollector and InkOverlay Objects Events

Most InkCollector and InkOverlay object events are raised on the ink thread. Only the mouse events for these objects are raised on the UI thread. For example, for the InkCollector object, the MouseDown event is raised on the UI thread, and the CursorDown event is raised on the ink thread.

Ink Object and Strokes Collection Events

The Ink object and Strokes collection events may come from the ink thread or the UI thread. When your application manipulates the Ink object or Strokes collection, the event is generated in the UI thread. When the InkCollector or the InkOverlay object updates the Ink object or Strokes collection, the event is generated in the ink thread.

The InkPicture and InkEdit controls operate in a single-threaded apartment (STA). When the InkPicture or InkEdit control updates the Ink object or Strokes collection, the event is raised on the UI thread.

Recognition Events

Recognition events are raised on the UI thread or the background recognition thread.

Pen Input Panel Events

Pen input panel events are raised on the thread in which the PenInputPanel object is created.