public SlaveSimulatorHost(IMasterContext masterContext, 
            IEnumerable<ISlave> slaves, 
            double characterTimeout,
            double messageTimeout)
        {
            if (masterContext == null) throw new ArgumentNullException(nameof(masterContext));
            if (slaves == null) throw new ArgumentNullException(nameof(slaves));

            _masterContext = masterContext;
            _characterTimeout = characterTimeout;
            _messageTimeout = messageTimeout;

            foreach (var slave in slaves)
            {
                _slaves.Add(slave.SlaveId, slave);
            }

            var task = new Task(() =>
            {
                try
                {
                    using (var master = _masterContext)
                    {
                        _port = master.Master.Transport.GetStreamResource();

                        _listener = new PromiscuousListener(_port);

                        _listener.Sample += OnSample;

                        _listener.Listen();
                    }
                }
                catch (Exception ex)
                {
                    //This will exception out when the port is killed
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    _listener.Sample -= OnSample;

                    _listener = null;
                }
            });

            //Create the timer
            _timer = new System.Timers.Timer
            {
                AutoReset = false

            };

            _timer.Elapsed += TimerElapsed;

            task.Start();
        }
        public CaptureHost(string path, IMasterContext masterContext)
        {
            if (masterContext == null) throw new ArgumentNullException(nameof(masterContext));

            _masterContext = masterContext;

            var task = new Task(() =>
            {
                try
                {
                    using (var writer = new CaptureFileWriter(path))
                    {
                        //Get the port
                        var port = masterContext.Master.Transport.GetStreamResource();

                        using (_listener = new PromiscuousListener(port))
                        {
                            _listener.Sample += (sender, args) =>
                            {
                                writer.WriteSample(args.Sample);

                                OnSampleReceived();
                            };

                            _listener.Listen();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            });

            //Start up this awesome task
            task.Start();
        }