PC Review


Reply
Thread Tools Rate Thread

ContextSwitchDeadlock

 
 
Benjamin Vigneaux
Guest
Posts: n/a
 
      17th Jun 2008
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.

 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      17th Jun 2008
On Jun 17, 3:42 pm, "Benjamin Vigneaux" <b...@mi.cl> wrote:

<snip>

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


My guess is that you're doing this in the UI thread. Don't - use a
BackgroundWorker instead.

Jon
 
Reply With Quote
 
Benjamin Vigneaux
Guest
Posts: n/a
 
      17th Jun 2008
Jon, Peter, thnx for your help..i'll look into it...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ContextSwitchDeadlock was detected =?Utf-8?B?U3JpbWFu?= Microsoft Dot NET Framework 7 20th Jun 2008 12:01 PM
ContextSwitchDeadlock =?Utf-8?B?Z3V5?= Microsoft Dot NET 2 9th Jun 2007 01:09 PM
ContextSwitchDeadlock Problem Kalpana Microsoft C# .NET 7 14th Feb 2007 10:53 AM
ContextSwitchDeadlock =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= Microsoft C# .NET 13 28th Apr 2006 07:32 PM
ContextSwitchDeadlock =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= Microsoft ADO .NET 4 26th Apr 2006 12:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:30 PM.