0

My code looks in a directory for .zip files and extracts them to a temporary folder structure for deletion later.

Occasionally, I get the ContextSwitchDeadlock was detected error and when I investigate where this is occurring, its during the unzipping of the zip files.

As a result, I'd like to move this into a background worker thread but can't for the life of me figure out where to start with background worker.

Any help would be much appreciated.

I guess I'm going to need to pass the list of zipfiles into the background worker thread but have had no success so far.

The first line of code where the zipfiles are unzipped is: foreach (FileInfo fz in ZipFiles) { does the unzipping stuff }

So I want to put this entire foreach loop in a background worker (i think?)

  • also, these xip files are large and contain crash.dmp files which can be up to a hundred MB –  Apr 23 '14 at 10:42
  • It is not an error, just a diagnostic generated by the debugger. You can easily turn it off with Debug + Exceptions, open the Managed Debugging Assistants node, untick the "ContextSwitchDeadlock" box. Or write better code, nothing that pretty about hanging up your user interface for a minute. Simply run the code on a worker thread, use the BackgroundWorker or Task class. – Hans Passant Apr 23 '14 at 13:14
  • Could you provide an example of how I could move the unzip code into a separate worker thread or background worker? –  Apr 23 '14 at 14:35

0 Answers0