Home Forums Legacy SDKs eyeTracker.Dispose() sometimes hangs if called during calibration Reply To: eyeTracker.Dispose() sometimes hangs if called during calibration


Hi Joseph,
I have tried to reproduce the problem but without success.

When you say that it sometimes hangs, how often is “sometimes”?

I built this model application to try out what happens when the app exits while a calibration is ongoing. Can you please have a look and tell me if I do something differently from your app? Or, even better, if you can modify the code so that it sometimes hangs? I use VS2013 btw.

Starting from a default WPF C# app, I modified the main window like so:

<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
            <Button Command="New" Padding="20">Start calibration</Button>

And the App.xaml.cs like so:

namespace WpfApplication1
    using System.Diagnostics;
    using System.Windows;
    using System.Windows.Input;
    using Tobii.Gaze.Core;

    public partial class App : Application
        private EyeTracker _tracker;
        //private Timer _timer;

        public App()
            var url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker();
            Debug.Assert(url != null); // if this fails: please connect tracker!

            _tracker = new EyeTracker(url);
            _tracker.RunEventLoopOnInternalThread(_ => { });
            _tracker.ConnectAsync(_ => { });

            var binding = new CommandBinding(ApplicationCommands.New, OnStartCalibration, (s, e) => e.CanExecute = true);
            CommandManager.RegisterClassCommandBinding(typeof(Window), binding);

        private void OnStartCalibration(object sender, ExecutedRoutedEventArgs e)
            _tracker.StartCalibrationAsync(errorCode =>
                    Trace.WriteLine(string.Format("Start calibration: {0}", errorCode));

            //_timer = new Timer(_ =>
            //    {
            //        Dispatcher.BeginInvoke(new Action(() =>
            //            {
            //                MainWindow.Close();
            //            }));
            //    }, null, 1000, Timeout.Infinite);

        private void NextCalibrationPoint()
            Trace.WriteLine("Calling AddCalibrationPointAsync");
            _tracker.AddCalibrationPointAsync(new Point2D(), (errorCode2 =>
                Trace.WriteLine(string.Format("Add calibration point: {0}", errorCode2));

        protected override void OnExit(ExitEventArgs e)
            Trace.WriteLine("Disposing tracker");
            Trace.WriteLine("Disposing tracker done");


The app runs an infinite calibration sequence when you press the button. So the idea is to start it and then close the window.

You can also get the window to self-destruct after a delay by uncommenting the commented-out lines.