/// <summary> /// Uploads the given block and makes sure it gets placed /// </summary> private bool Send(UploadRequestEvent request) { IBlockPlaceSendEvent e = request.SendEvent; request.SendTries++; // If not block already exists if (!this.IsUploaded(e)) { this.RaiseEvent(e); this.EnqueueCheck(request); return true; } request.Verified = true; return false; }
/// <summary> /// Adds the request to the lag checking queue /// </summary> /// <param name="request"></param> private void EnqueueCheck(UploadRequestEvent request) { IBlockPlaceSendEvent e = request.SendEvent; lock (this._checkQueue) { if (!this._uploaded[(int)e.Layer, e.X, e.Y] && request.SendTries < 50) { this._uploaded[(int)e.Layer, e.X, e.Y] = true; this._checkQueue.Enqueue(request); } } }
private void OnUploadRequest(object sender, UploadRequestEvent e) { if (e.SendEvent.Layer > Layer.Background || e.SendEvent.X >= this._world.RoomWidth || e.SendEvent.Y >= this._world.RoomHeight) throw new IndexOutOfRangeException("The given block is not inside the boundaries of the room!"); Action task = () => { if (this.Send(e)) { Thread.Sleep(10); } if (this._workThread.Count == 0) { // Make sure this is the last work item // BugFix for single core machines this.SynchronizePlatform.Do(() => { if (this._workThread.Count != 0) return; this.DoLagCheck(true); }); } }; if (e.IsUrgent) { this._workThread.QueueFront(task); } else { this._workThread.QueueBack(task); } }
private void OnUploadRequest(object sender, UploadRequestEvent e) { Action task = () => { if (this.Send(e)) { Thread.Sleep(10); } if (this._workThread.Count == 0) { // Make sure this is the last work item // BugFix for single core machines this.SynchronizePlatform.Do(() => { if (this._workThread.Count != 0) return; this.DoLagCheck(true); }); } }; if (e.IsUrgent) { this._workThread.QueueFront(task); } else { this._workThread.QueueBack(task); } }