private void MonitorMemory()
        {
            if (Debug.GC(true) > 60000)
            {
                return;
            }

            Rebug.Print("RAM critically low... pausing actions.  Freemem: " + Debug.GC(true) + "  TimeStamp: " + Clock.Instance.ElapsedMilliseconds);

            foreach (WorkItem action in _pauseableWorkItems)
            {
                action.Stop();
            }
            //var currentCount = _logger.PendingItems;
            while (_logger.PendingItems > 0)
            {
            }

            Rebug.Print("Resuming paused actions... Current FreeMem: " + Debug.GC(false) + "  TimeStamp: " + Clock.Instance.ElapsedMilliseconds);

            foreach (WorkItem action in _pauseableWorkItems)
            {
                action.Start();
            }
        }
        public CustomMagUpdater(int dataCount, Cpu.AnalogChannel magPin)
        {
            _magPin    = new AnalogInput(magPin);
            _dataCount = dataCount;
            Rebug.Print("Initializing high frequency custom magnetometer update cycle");
            _dataArray = new byte[dataCount + MetaDataCount + TimeDataCount];
            _workItem  = new WorkItem(DumpMagData, ref _dataArray, loggable: true, persistent: true, pauseable: true);

            _dataArray[0] = (byte)PacketType.StartByte;
            _dataArray[1] = (byte)PacketType.FMagDump;
        }