PST SDK  5.2.0.0-0eac0f6
minimal.cs

This example can be found in Development\examples\csharp\minimal\minimal.cs.

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 Development\Redist directory into the build directory).

// Copyright PS-Tech B.V. All Rights Reserved.
using System;
using System.Threading;
using PSTech.Pstsdk;
namespace PSTech.Minimal
{
public class Minimal
{
static 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.
Tracker tracker = new Tracker();
// Register the listener object to the tracker server.
tracker.AddTrackerListener(OnTrackerData);
// 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.
}
finally
{
// Make sure that the connection to the PST Tracker is shut down properly.
Tracker.Shutdown();
}
}
}
}
PSTech.Pstsdk
Definition: CApi.cs:8
PSTech.Pstsdk.ErrorStatus
ErrorStatus
Tracker error messages enum class.
Definition: ErrorHandler.cs:16
Exception
PSTech
Definition: CApi.cs:8