Error Handling Considerations for the StylusInput API

Unhandled exceptions thrown by a plug-in are caught by the RealTimeStylus object. When a plug-in throws an exception, the normal flow of data is interrupted. The RealTimeStylus object:

  1. Creates an ErrorData object (in managed code).
  2. Calls the Error method (in managed code, either the Microsoft.StylusInput.IStylusSyncPlugin.Error or Microsoft.StylusInput.IStylusAsyncPlugin.Error method) of the plug-in that threw the exception.
  3. Calls the Error method of the remaining plug-ins in that collection.
  4. If the plug-in that threw the exception is a synchronous plug-in, the ErrorData object (in managed code) is added to the output queue.
  5. The RealTimeStylus object resumes normal processing of the original data.

If a plug-in throws an exception from its Error method, the RealTimeStylus object catches the exception but does not generate a new ErrorData object. For more information about how ErrorData is added to the queue, see Plug-in Data and the RealTimeStylus Class.

The RealTimeStylus object does not stop processing data from the tablet pen's data stream when one of its plug-ins throws an exception. Depending on your design, some of your plug-ins may need to subscribe to the ErrorData notification and modify their behavior when an exception occurs.