public void Cancel() { if (Interlocked.CompareExchange(ref cancelled, 1, 0) == 0) { parent.Remove(this); worker.Dispose(); if (!outputFused && Interlocked.Increment(ref wip) == 1) { queue.Clear(); } } }