Click here to Skip to main content
12,351,441 members (36,872 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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:
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 27-Feb-13 21:00pm
Dexter111.1K
Edited 27-Feb-13 21:02pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100