CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2011
    Posts
    19

    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

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    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.

  3. #3
    Join Date
    May 2007
    Posts
    1,546

    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
  •  





Click Here to Expand Forum to Full Width

Featured