ContextSwitchDeadlock

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello!!

Well... this code works perfectly... what it does:
It navigates a folder tree of N-Levels and it moves all the files from each folder to the root folder, then deletes the empty folders.

protected void MoveStuff(DirectoryInfo RootFolder)
{
if (RootFolder.FullName != textBoxROOTpath.Text)
{
foreach (FileInfo NextFile in RootFolder.GetFiles())
{
NextFile.CopyTo(textBoxROOTpath.Text+"\\"+NextFile.Name,true);
NextFile.Delete();
progressBar.PerformStep();
}
}

foreach (DirectoryInfo NextFolder in RootFolder.GetDirectories())
{
MoveStuff(NextFolder);
}
foreach (DirectoryInfo EmptyFolder in RootFolder.GetDirectories())
{
EmptyFolder.Delete();
}
}

My problem is, that it gets ugly with large files because of memory usage, I guess.... the program becomes nonresponsive for a while, even though, most of the cases, it will become responsive again... in one od the hungups I came across this...

***
ContextSwitchDeadlock was detected:

The CLR has been unable to transition from COM context 0x1f6050 to COM context 0x1f61c0 for 60 seconds.

The thread that owns the destination context/apartment is most likely either doing a non pumping wait
or processing a very long running operation without pumping Windows messages.

This situation generally has a negative performance impact and may even lead to the application becoming
non responsive or memory usage accumulating continually over time.

To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives
(such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
***

I kind of understand what it says... but I do not know how to implement a solution...

Any ideas?

Benjamin.

.



Relevant Pages

  • Re: Windows XP hangs when I right click
    ... Windows displays the context menu. ... * When you click "Play All" in the Music or Videos folder Common Tasks, ... These problems are caused by a poorly coded context menu handler. ... Using ShellExView to determine the Context-menu handler causing the ...
    (microsoft.public.windowsxp.general)
  • Re: Desktop Icon Drop Down Menus
    ... You can use ShellExView to disable the context menu handlers. ... Set Open as default for Folder in Folder Options. ... And Search also opens instead of the folder when double clicking. ...
    (microsoft.public.windowsxp.basics)
  • Re: File selection and new folders
    ... dorayme wrote: ... intuitively easy to navigate, you can get a new folder, select exactly ... context menu item, this would happen. ... set the_selection to the selection ...
    (comp.sys.mac.system)
  • Re: explorer.exe will not open
    ... C:\Documents and Settings\Your Name Here\Start Menu folder with the folders ... that you have a messed up context menu handler and it's ... MS-MVP Windows Shell/User ... am going to install an external sound card but wondered if there would ...
    (microsoft.public.windowsxp.general)
  • Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
    ... ExtendedPropertyType exProp1 = new ExtendedPropertyType; ... The name 'ExtendedFieldURI' does not exist in the current context ... folderID of the Public folder you want to create the item in. ... With the result of the findFolder operation eg ...
    (microsoft.public.exchange.development)