private void OnExpired(object sender, JobDoneArgs e) { _jobRunner.Stop(); var dq = e.DataQueue; var parentTree = dq.ParentTree; parentTree.RemoveNode(dq.Data); var hCount = parentTree.Count; var width = dq.BaseNode.Data.Width; var height = dq.Data.Height; if (hCount == 0) { RemovePackage(width); } var pkg = new Package() { Count = 0, Width = width, Height = height }; OnInventoryChange?.Invoke(this, new InventoryChangeEventArgs(pkg)); _jobRunner.Start(); }
protected override void DoJob() { var head = _queue.Peek(); if (head != null) { var diff = DateTime.Now.Subtract(head.Data.Data.InsertionDate).TotalMilliseconds; if (diff > ExpiretionThreshHoldInMilliseconds) { JobDoneArgs args = new JobDoneArgs(_queue.Dequeue()); OnJobDone?.Invoke(this, args); } } }