Long Running Operations Windows Forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • enreil
    New Member
    • Jan 2007
    • 86

    Long Running Operations Windows Forms

    So I'm working on a Windows Forms for VB.NET in VS 2005 that is highly computational. It gets a ton of data from a database and eventually spits out a report based on the data. Because of the time it takes to run, when I debug I get the following message:

    "The CLR has been unable to transition from COM context 0x1a01b0 to COM context 0x1a0320 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 CoWaitForMultip leHandles) and routinely pump messages during long running operations."

    Any advice on how to handle this situation? I've tried to make my code as efficient as possible, so I'm going to have to deal with these long periods of computation.

    Thanks.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    IMO - web designers are smarter with handling large files than we web/ windows developers are with data. What do I mean? They think about what they can preload to the browser and what can happen later.

    Can't comment on your particular case Enreil, but some developers use SQL queries that are too general and try to manage all of the data at once instead of 'packets'. I guess my suggestion is that it is great that you have optimized your code - have you optimized your queries? Database design and optimized queries are important for the transition from medium to large applications.
    My two cents worth...

    Of course if you have already got a good database design and well structured queries, then you may want to look at managing your threads.

    Comment

    • enreil
      New Member
      • Jan 2007
      • 86

      #3
      Thanks for your thoughts. My SQL queries are pretty basic select statements, so I don't know that there's a whole lot of optimization I can do in that regard. The real holdup in this project is the DB access time. The DB is located several time zones away and it just takes a long time to go there and bring the data back. I'm working with tens of thousands of rows of data, so I try to mitigate the overhead caused by the long DB trips by grabbing all of the data I need in one trip, stashing it in memory, and thenselecting what I need from there. I didn't research this tactic, but it seemed logical. The alternative is to make multiple trips to get the specific data I need, so while my SQL queries would runs faster by pulling less data, the time to get there and back makes that an undesirable approach.

      Anyways, I'll look into better thread management and see where that takes me. Appreciate the feedback.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Any progress using thread management?

        Comment

        • enreil
          New Member
          • Jan 2007
          • 86

          #5
          Thanks for asking. Yes, improving thread management gets rid of the error - I just added the line

          System.Threadin g.Thread.Curren tThread.Join(1)

          at appropriate places in my code. It'll do for now. Looking back at my code, I think there is still room to make my code more efficient, but right now I just need the app to do its job. Thanks for your assistance!

          Originally posted by kenobewan
          Any progress using thread management?

          Comment

          • AricC
            Recognized Expert Top Contributor
            • Oct 2006
            • 1885

            #6
            Originally posted by enreil
            Thanks for your thoughts. My SQL queries are pretty basic select statements, so I don't know that there's a whole lot of optimization I can do in that regard. The real holdup in this project is the DB access time. The DB is located several time zones away and it just takes a long time to go there and bring the data back. I'm working with tens of thousands of rows of data, so I try to mitigate the overhead caused by the long DB trips by grabbing all of the data I need in one trip, stashing it in memory, and thenselecting what I need from there. I didn't research this tactic, but it seemed logical. The alternative is to make multiple trips to get the specific data I need, so while my SQL queries would runs faster by pulling less data, the time to get there and back makes that an undesirable approach.

            Anyways, I'll look into better thread management and see where that takes me. Appreciate the feedback.
            What kind of connection do you have between the two sites?

            Comment

            • enreil
              New Member
              • Jan 2007
              • 86

              #7
              Between my app and the DB? The DB is Oracle, and I'm just using a basic Oracle connection string with the Datasource, username, and password. Is that what you're getting at?

              Originally posted by AricC
              What kind of connection do you have between the two sites?

              Comment

              Working...