waiting form get disappeared while executing long process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skavinkar
    New Member
    • Jun 2012
    • 23

    waiting form get disappeared while executing long process

    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:
    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??
  • Mikkeee
    New Member
    • Feb 2013
    • 94

    #2
    skavinkar, any task that's going to take that long will probably make your app unresponsive until it's finished. I would recommend that you place your long running function in another thread so the UI remains responsive. A fairly easy solution would be to place a background worker on your form. The background worker is nice because it allows you to show progress/status on the UI thread while keeping the main routine on another thread.

    See the MSDN help: http://msdn.microsoft.com/en-us/libr...undworker.aspx

    Comment

    Working...