|
-
January 28th, 2012, 05:47 PM
#1
delay in reading data from hard disk
hello im building an application which requires retrieval of mp3 files from folders and show them in a treeview.but it's taking a lot of time and the screen freezes showing the following error-
"ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x216910 to COM context 0x216a80 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.
"
how can this be overcome?i have tried to use backgroundworker but still unsure what to do.please help
-
January 28th, 2012, 06:41 PM
#2
Re: delay in reading data from hard disk
application which requires retrieval of mp3 files from folders and show them in a treeview
So, how are you building the list?
In any case, does it appear only in Debug mode, or also if you lanch the exe?
Background worker could be a solution, but I was wondering what com or unmanaged code are you using (if any)
Have a look at this:
http://dotnetdud.blogspot.com/2009/0...tion-from.html
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
January 28th, 2012, 09:18 PM
#3
Re: delay in reading data from hard disk
The odds are he's reading a bunch of MP3s from the main GUI thread which is blocking updates from occurring. He needs to do them in a background thread and post the updates the the UI to avoid making the UI non responsive.
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|