public void ExecuteFrame(PageCache cache) { if (0 == _waitQueue.Count) { return; } try { while (_waitQueue.Count != 0) { var key = _waitQueue.Dequeue(); PagePointer ptr; cache.AddContext(key, out ptr); Page page; if (!cache.TryGetPage(ptr.index, out page)) { _capturing.Enqueue(ptr.index); } } while (_capturing.Count != 0) { var pageIndex = _capturing.Dequeue(); Task.Factory.StartNew(() => { var page = _stream.Capture(pageIndex * Config.LENGTH_PAGE, (pageIndex + 1) * Config.LENGTH_PAGE).Flush(); page.index = pageIndex; cache.AddPage(page); }); } } catch (KeyNotFoundException e) { } catch (Exception e) { } finally { _waitQueue.Clear(); _capturing.Clear(); } }