Example #1
0
        private void BroadcastingThreadMethod()
        {
            try
            {
                using (_observer = new InputDeltaObserver())
                {
                    using (StartCommunicator())
                    {
                        _observer.StartCapturing();
                        LogExceptions(_observer.ProcessingExceptions);
                        _communicator.Start();

                        OnDriversReady();

                        while (_isRunning)
                        {
                            lock (this)
                            {
                                _observer.UpdateTick();
                                LogExceptions(_observer.ProcessingExceptions);

                                if (_observer.DirtiedDeltas.Count > 0)
                                {
                                    //Filter dirtied deltas
                                    //TODO

                                    //Serialize and send
                                    var dirtied = _observer.SerializeDirtied();
                                    _communicator.Broadcast(dirtied);
                                }
                            }

                            Thread.Sleep(_updateTick);
                        }

                        _communicator.Stop();
                        _communicator.Dispose();
                        _communicator = null;
                    }
                    _observer.StopCapturing();
                    _observer.Dispose();
                    LogExceptions(_observer.ProcessingExceptions);
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Example #2
0
        private void BroadcastingThreadMethod()
        {
            try
            {
                using (Observer = new InputDeltaObserver())
                {
                    Observer.StartCapturing();
                    LogExceptions(Observer.ProcessingExceptions);


                    SetupBroadcaster();
                    _isBroadcasting = true;
                    while (_isBroadcasting)
                    {
                        Observer.UpdateTick();
                        LogExceptions(Observer.ProcessingExceptions);

                        if (Observer.DirtiedDeltas.Count > 0)
                        {
                            var dirtied = Observer.SerializeDirtied();
                            BroadcastString(dirtied);
                        }

                        Thread.Sleep(_updateTick);
                    }

                    Observer.StopCapturing();
                    Observer.Dispose();
                    LogExceptions(Observer.ProcessingExceptions);
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }