How to Cancel Compression

May 16, 2011 at 8:16 PM

Hello, I am trying to cancel a compression operation in the "Compressing" event by setting e.Cancel to true. I set e.Cancel to true when the BackgroundWorker.CancellationPending property is set to true after calling the BackgroundWorker.CancelAsync() method. The SevenZipCompressor object is instantiated and started during the BackgroundWorker's DoWork event. I can verify that when CancellationPending is true and I set e.Cancel to true during the Compressing event, compression still continues until the end. Am I doing something wrong or can you not cancel a compression operation? 

May 18, 2011 at 10:34 PM

I ended up using Thread.Abort() after getting the thread that the compression was occurring on. It's not a pretty solution, but it works.