Home Forums Reply To:

#9385
Dmitry
Participant

Hi, Grant!
Thank you for example. But in your code ManualResetEvent class is not recognized. A ConntctionStateCehangedEventArgs not recognized too. May be, you missed a using directive or link to some dll:

using System;
using Tobii.Interaction;

namespace serialWithSharp
{
    public class Program
    {
        public static void Main()            
        {
            Tobii.Interaction.Host host = new Host();
            host.EnableConnection();

            ManualResetEvent signal = new ManualResetEvent(false);
            host.Context.ConnectionStateChanged += delegate (object sender, ConnectionStateChangedEventArgs args)
              {
                  if (args.State == ConnectionState.Connected)
                      signal.Set();
              };

            if(signal.WaitOne(100))
            {
                var serialNumber =
                host.Context.GetState(Tobii.Interaction.Framework.StatePaths.EyeTrackingInfoSerialNumber).GetStateValueOrDefault<string>();

                Console.WriteLine(serialNumber);
            }
            else
            {
                Console.WriteLine(@"Connection not established!");
            }
        }
    }
}

Best Wishes,
Dmitry