To communicate with a smartpen using the PenComm Client Library, desktop applications have to perform the following steps:
This step must be performed before using the PenComm Client Library. Normally, the desktop application initializes the library at startup by creating a Smartpens object.
Your application should create only one instance of Smartpens, passing appropriate parameters to the constructor. Initialization of the PenComm Client Library will take place automatically. See the Get Pen Information Example for more detail.
After initializing the library, the application can use methods of the Smartpens object to communicate with smartpens. See the Classes for more detail.
After an application is finished using the Smartpens object, the garbage collector will destroy the object. Upon destruction of the Smartpens object, the PenComm Client Library is automatically deinitialized and resources are freed.
IMPORTANT NOTES
A ServiceHandle object represents a communication pipe. It is created by the PenComm Service when communication is opened to a smartpen. In general, your code does not need to deal with ServiceHandles. However, many PenComm API methods have an overloaded version that takes a ServiceHandle parameter. For example: public bool Update(PenAPI.ProgressCallback callback, object userData, ServiceHandle serviceHandle) of the SmartpenHardware class.
In some situations, re-using an explicit service handle can optimize communication with the smartpen. Methods called using the same service handle value will share that handle.
To create a service handle, call the Smartpen.Open method, which returns a ServiceHandle.
To close a service handle, call the Smartpen.Close method. Doing so closes the communication channel and frees resources. All service handles that are explicitly opened with Smartpen.Open must be explicitly closed by calling Smartpen.Close.
Please keep in mind that if you pass a service handle of 0 to the overloaded method, the behavior is the same as the simple version of the method--a service handle is automatically opened and closed within the method call.
An application can have multiple threads communicating with a smartpen. Make sure the same service handle is not used by different threads at the same time.