Export (0) Print
Expand All

ContactTarget Class

Surface 1.0 SP1
Represents a top-level window for which Microsoft Surface input should be enabled.

Namespace: Microsoft.Surface.Core
Assembly: Microsoft.Surface.Core (in microsoft.surface.core.dll)

Dim instance As ContactTarget

public class ContactTarget : IDisposable
public class ContactTarget implements IDisposable
public class ContactTarget implements IDisposable

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.

#region InitContactTarget1
this.contactTarget =
    new ContactTarget(this.Window.Handle, EventThreadChoice.OnBackgroundThread);
this.contactTarget.ContactAdded +=
    new EventHandler<ContactEventArgs>(ContactTarget_ContactAdded);

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:

  1. 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.

  2. 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.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Microsoft Surface 1.0 SP1, Windows Vista Ultimate, Windows Vista Enterprise, Windows Vista Business

Target Platforms

Microsoft Surface 1.0 SP1
© 2015 Microsoft