public void Start()
        {
            if (_running) return;

            _currentHandle = _queue.Add(DateTime.Now + _interval, Callback, null);

            _running = true;
        }
        public void Stop()
        {
            if (!_running) return;

            _running = false;

            if (_currentHandle != null) _currentHandle.Cancel();

            _currentHandle = null;
        }
        public void CheckForBuildTask(DateTime fireAt, object state)
        {
            if (_waitingChunks.Count == 0)
            {
                _timerHandle = _host.Reactor.AddTimer(new TimeSpan(0, 0, 0, 0, _settings.FileChunkPollWait), CheckForBuildTask, null);
                return;
            }

            FileChunkMessage next = _waitingChunks.Dequeue();

            if (!WriteChunkToFile(next))
            {
                throw new InvalidOperationException("Chunk failed, this should be logged and contain some meaningful data in future");
            }

            //if (NextChunkRequested != null)
            //{
            //    NextChunkRequested(this, )
            //}

            _timerHandle = _host.Reactor.AddTimer(DateTime.Now, CheckForBuildTask, null);
        }
        public void ReceiveChunk(FileChunkMessage message)
        {
            if (_timerHandle != null)
            {
                _timerHandle.Cancel();

                _waitingChunks.Enqueue(message);

                _timerHandle = _host.Reactor.AddTimer(DateTime.Now, CheckForBuildTask, null);
            }
        }
        public void Open(IServiceHost host)
        {
            _host = host;
            _fileBuilders = new Dictionary<string,FileRebuilder>();

            _waitingChunks = new Queue<FileChunkMessage>();

            _timerHandle = host.Reactor.AddTimer(DateTime.Now, CheckForBuildTask, null);
        }
        void Callback(DateTime fireAt, object state)
        {
            if (!_running) return;

            _callback(fireAt, _state);

            _currentHandle = _queue.Add(DateTime.Now + _interval, Callback, null);
        }