Solved

How do avoid time out expired in my VB 2008 aplication

Posted on 2011-03-23
7
929 Views
Last Modified: 2012-06-27
I have a form where I call a lot of  stored procedures in a MySQL database. In the procedures are same queries which execute updates, insert into etc.

Sometimes, during debugging, depending on the size of tables included in the queries, the program stops and appears the message below:

"The CLR has been unable to transition from COM context 0x1b0f58 to COM
context 0x1b10c8 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."

In the site there is a solution in C#, but I would like a solution for VB2008.

I Would like to Know if it is possible a solution by creating a new thread.

Thanks.

0
Comment
Question by:JGonzaga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35198466
Yes...threading should solve your issue.  The easiest solution is to use the BackgroundWorker() and place your lengthy DB calls in the DoWork() handler.  If you need to update the GUI then use the ProgressChanged() and/or RunWorkerCompleted() events:
http://msdn.microsoft.com/en-us/library/8xs8549b.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
0
 

Author Comment

by:JGonzaga
ID: 35199002
I´ve tried the solution with backgroundworker, but in the code there is a problem, because the varable BackgroundWorker, in the statement below, are not be recognized.

 Dim CalcEstq As BackgroundWorker = CType(sender, BackgroundWorker)

 In my code I´ve repleced Worker by CalcEstq
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35199179
The VARIABLE "CalcEstq" is not being recognized?...or the BackgroundWorker() TYPE is not being recognized?

What is the error?...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JGonzaga
ID: 35199219
Sorry!

The Type
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35199251
You can either fully qualify the BackgroundWorker like this:

    System.ComponentModel.BackgroundWorker

Or add an Imports statement to the top of your code:
Imports System.ComponentModel
Public Class Form1

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim CalcEstq As BackgroundWorker = CType(sender, BackgroundWorker)
        ' ...
    End Sub

End Class

Open in new window

0
 

Author Comment

by:JGonzaga
ID: 35201885
Finaly the routine works, but the time out remains. I´ve tried to change my string connection adding Connect time out= 600. I´ve changed the number of seconds several times, Sometimes i´ve put large nummbers, but, in spite of this I can´t avoid the time out.

I can´t undertand the reason of the time out because the process is executed in background.

Thanks.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 35202116
They are two completely different kinds of errors.

Your original error had to do with the long task blocking the message pump (which the backgroundworker fixes).

The second error has nothing to do with being in the foreground or background thread, and is really a function of the way the database call works.  I don't know how to fix that as I'm not a database guy...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question