Form goes blank

G

Guest

In VB.net, I have win form programs that do database update operations that
take several minutes or longer. Several actions such as switching windows or
clicking a control during these operations leave me with a blank form (all
white space inside the form borders) or with a frozen form that will not
display refreshed controls. When the db operations are done, the forms
repaint just fine. What’s happening and what can I do about it? Thanks.
 
D

Dr Screwup

Your application can't update itself. Look into using a thread or a
System.Timers (not the System.Windows.Form.Timer). Or you can try
Application.DoEvents.
 
I

Imran Koradia

Run your database operation in a seperate thread. This will prevent the UI
from locking/not responding.

Private Sub myDBOperation()
' long running db operation..
End Sub

Private m_Thread As New _
System.Threading.Thread(AddressOf myDBOperation)

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
m_Thread.Start()
End Sub

Note that the target of AddressOf in the Thread's constructor can only be a
Sub and not a Function.

More on threading:
http://msdn.microsoft.com/library/d...html/frlrfSystemThreadingThreadClassTopic.asp
http://msdn.microsoft.com/library/d.../en-us/dv_vstechart/html/vbtchasyncprocvb.asp

hope that helps..
Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top