Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to display waiting message which is actually a form while long process is running in some different file. Issue i am facing is the form get disappeared once the process gets started but its still active and running the process

My code:
VB
Dim objWait As New frmWaitupdate
   Dim strReply As String

   Dim ischange As Boolean
   Dim obj1 As New MyBO.UpdateSchemaBO()
   ischange = obj1.CheckSchemaChanges(Application.ProductVersion.ToString())

   If ischange = True Then

       lblMsg.Text = "Schema changes found please wait  Please wait."

       obj1.AddVersionTable(Application.ProductVersion.ToString())
       Me.Visible = True

       strReply = obj1.UpdateSchema(Me)
       If strReply <> "" Then
           MessageBox.Show(strReply, "abc")
       Else
           MessageBox.Show("Schema updated successfully", "abc")
       End If


       'objWait.Hide()
   ElseIf ischange = False Then

       MessageBox.Show("No schema changes found", "abc")


       End If

   End If

As the process goes in UpdateSchema() which takes around 30-45 sec to finish the form gets disappear.Is there any way to keep the form intact on screen until my process gets complete??
Posted
Updated 27-Feb-13 21:02pm
v2

1 solution

Your problem is that your long-running code is running on the UI (startup) thread and preventing any windows messages from being processed, like WM_PAINT which causes your windows to repaint themselves.

Your solution is to move the long-running code to a background thread. You can do this in a number of different ways, like using the Thread class, the Task Parallel Library, the BackgroundWorker (suggested!) component, or what have you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900