/// <summary> /// Flushs the update queue. Takes the list of all updates queued for the client and calls the client's callback, passing this list as parameter /// </summary> private void FlushUpdateQueue() { while (true) { bool gotLock = false; try { QueueLock.Enter(ref gotLock); if (UpdateQueue.Count > 0) { InvokeClientCallbacks(); UpdateQueue.Clear(); } } finally { if (gotLock) { QueueLock.Exit(); } } // Wait for updates to accumulate (to send them in batches) Thread.Sleep(10); } }
public void RequestUpdate(TextAreaUpdate update) { if (UpdateQueue.Count == 1 && UpdateQueue[0].TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) { // if we're going to update the whole text area, we don't need to store detail updates return; } if (update.TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) { // if we're going to update the whole text area, we don't need to store detail updates UpdateQueue.Clear(); } UpdateQueue.Add(update); }
/// <inheritdoc /> public void ClearChunks() { UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); var chunks = Chunks.ToArray(); Chunks.Clear(); Scheduled.Clear(); _renderedChunks = new ChunkData[0]; foreach (var chunk in chunks) { chunk.Value.Dispose(); } }
/// <inheritdoc /> public void Dispose() { if (_disposed) { return; } try { //Graphics?.Dispose(); BlockLightCalculations?.Dispose(); BlockLightCalculations = null; SkyLightCalculator?.Dispose(); SkyLightCalculator = null; _renderSampler.Dispose(); CancellationToken.Cancel(); UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); foreach (var chunk in Chunks) { chunk.Value.Dispose(); } Chunks.Clear(); foreach (var rendered in _renderedChunks) { rendered.Dispose(); } _renderedChunks = null; } finally { _disposed = true; } }
/// <inheritdoc /> public void Dispose() { //Graphics?.Dispose(); CancellationToken.Cancel(); UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); foreach (var chunk in Chunks) { chunk.Value.Dispose(); } Chunks.Clear(); foreach (var rendered in _renderedChunks) { rendered.Dispose(); } _renderedChunks = null; }