Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 15th, 2006, 6:04 AM   #1
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
ContextSwitchDeadlock

Last night I wrote a little application that splits files into individual parts of equal size. The program works greatly efficiently while parting files under 100mb, anything over 100mb and it obviously gets busier, but windows assumes that it is just hanging and results in my application being non responsive.

When it gets round to it, the message I get is 'ContextSwitchDeadlock' error...

http://msdn2.microsoft.com/en-us/library/ms172233.aspx

After looking here, and not really understanding this 100%, im here for help. How could I make my program more efficient, to run quicker with bigger files? Obviously, the bigger the file gets the harder the work, so how can I tell my program to let windows know its busy, and not frozen?

On the msdn page I dont understand this code, is it saying 'Add this code and windows will over look your programs time-taking procedures'? or what?.

any help is greatly appreciated.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Old Aug 15th, 2006, 8:40 AM   #2
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
it appears as if your thread is not pumping.
Quote:

Failure to Pump


When your STA thread is doing nothing else, it needs to be checking to see if any other threads want to marshal some calls into it. This is done with a Windows message pump. If the STA thread fails to pump, these incoming calls will be blocked. If the incoming calls are GUI SendMessages or PostMessages (which I think of as synchronous or asynchronous calls respectively), then failure to pump will produce an unresponsive UI. If the incoming calls are COM calls, then failure to pump will result in calls timing out or deadlocking.

If processing one incoming call is going to take a while, it may be necessary to break up that processing with intermittent visits to the message pump. Of course, if you pump you are allowing reentrancy to occur at those points. So the developer loses all his wonderful guarantees of single threading.
stolen from: http://blogs.msdn.com/cbrumme/archiv.../02/66219.aspx

are you doing all of this processing on your main thread? I believe the problem is that your application is being too big of a hog. I have no clue what's in your code so....

as the file gets bigger, however you have it implemented, it should not require any more resources than when working with a small file, it should simply take longer and nothing more, you might want to give it its own thread as well while its churning away. so try that and see what happens.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is online now   Reply With Quote
Old Aug 17th, 2006, 6:08 AM   #3
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
I found 'Application.DoEvents()' helps to carry on pumping messages and using a background worker to automatically organise threads stops the program from hanging, however it is my code that is fundementally flawed.

I meant to bring the code but foolishly left this morning without it.

Before I posted I was using a MemoryStream to copy data and then re-write it, however as this implies memory will get clogged with bigger files, obviously activites using this feature will vary in many aspects from PC to PC, I changed it then to write directly to a FileStream, but to no avail; As for this, it still seems to write all data into memory before writing it to the file, I then posted this thread.

I apologize for the lack of information initilally posted
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC