Assembly: Microsoft.Surface.Core (in microsoft.surface.core.dll)
In the following code example, the ContactTarget object for the application is instantiated to enable input events to be raised on a background thread, and an event handler for the ContactAdded event is established.
Exceptions thrown from event handlers behave differently depending on the EventThreadChoice value that is used to create a ContactTarget object. This is applicable only to the Core API layer.
The behaviors are:
OnBackgroundThread: The exception is thrown as expected and Microsoft Visual Studio stops the debugger in the event handler code. This behavior occurs because the event handler is simply a callback method. The actual exception is top most.
OnCurrentThread: The exception is thrown but Visual Studio stops the debugger at the wrong place in the stack frame (that is, outside of Game.Run). This behavior occurs because Post is used to invoke the event handler. The actual exception ends up nested as the InnerException of a new TargetInvocationException.