/// <summary> /// Generates a history from the recent items. /// </summary> /// <returns></returns> public IndexingActivityHistory GetHistory() { IndexingActivityHistory result; var list = new List <IndexingActivityHistoryItem>(_history.Length); lock (Lock) { for (int i = _position; i < _history.Length; i++) { if (_history[i] != null) { list.Add(_history[i]); } } for (int i = 0; i < _position; i++) { if (_history[i] != null) { list.Add(_history[i]); } } result = new IndexingActivityHistory(_unfinished) { State = _activityQueue.GetCurrentState(), Recent = list.ToArray() }; } return(result); }
/// <summary> /// Resets the history and returns with the starting state. /// </summary> public static IndexingActivityHistory Reset() { IndexingActivityHistory result; lock (Lock) { for (int i = 0; i < History.Length; i++) { History[i] = null; } _position = 0; _unfinished = 0; result = new IndexingActivityHistory() { State = DistributedIndexingActivityQueue.GetCurrentState(), Recent = new IndexingActivityHistoryItem[0] }; } return(result); }