PST SDK 7.0.0.0-ebe6e713
Loading...
Searching...
No Matches
minimal.cs

This example can be found in examples\csharp\minimal\minimal.cs. When the PST SDK has been installed through the PST Software Suite installer the examples can be found in the Development folder.

This is a bare minimum example showing how to connect to the PST SDK and how to register a listener to receive data.

Note that for simplicity reasons, this example does not take the recommended safety precautions to shut down the PST Tracker when the application shuts down. In an actual implementation, please follow the safety precautions recommended in the Safe Tracker Termination section of the Using PST SDK page of the manual. Examples of how to implement the safety precautions can be found in the other examples.

When compiling and running this example, please make sure that the required dependencies can be found by the executable (e.g. by copying the Redist directory into the build directory. When the PST SDK has been installed through the PST Software Suite installer the Redist folder can be found in the Development folder.).

// Copyright PS-Tech B.V. All Rights Reserved.
using System;
using System.Threading;
namespace PSTech.Minimal
{
public class Minimal
{
class MyTrackerListener : TrackerListener
{
public override void OnTrackerData(TrackerData data, ErrorStatus status)
{
// Do something with the tracker data in data
}
}
static void Main(string[] args)
{
// Implement error handling of PSTech.TrackerException exceptions to prevent
// improper PST Tracker shutdown on errors.
try
{
// Create an instance of the Tracker object using the default configuration path and file names.
// Wrap the Tracker in a using statement to ensure Dispose() is called automatically
using (Tracker tracker = new Tracker())
{
//Create tracker listener with callback functions for data and/or mode updates.
TrackerListener listener = new MyTrackerListener();
// Register the TrackerListener object to the tracker server.
tracker.AddTrackerListener(listener);
// Start the tracker server.
tracker.StartTracker();
// Wait for 10 seconds, allowing for the detection of tracking targets.
Thread.Sleep(10000);
}
}
catch (Exception e)
{
// Do something with the error.
}
}
}
}
Tracking information retrieved from tracker.
Definition TrackerData.cs:25
Main PST SDK class implementing tracker communication.
Definition Tracker.cs:198
void StartTracker()
Start tracking.
Definition Tracker.cs:524
void AddTrackerListener(TrackerListener listener)
Add a listener for tracker data and/or mode change reporting.
Definition Tracker.cs:476
Implements the TrackerListener class to receive tracking information and tracking mode updates.
Definition Tracker.cs:166
Definition CApi.cs:9
ErrorStatus
Tracker error messages enum class.
Definition ErrorHandler.cs:17