Hanging Message Box

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
I have a message that box that when I click on it the top portion of the message box shows for a few seconds after I click the OK botton. This is the code in the button.

VB.NET:
Private Sub btnstopcapture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstopcapture.Click
        ' variable to hold the body of the email message sent after the video is saved to the server 
        Dim strBody As String
        ' see whether or not the user wants to publish to the server or save to local drive
        If MessageBox.Show("Do you want to publish to the server?", "Publish Video", _
                 MessageBoxButtons.YesNo, MessageBoxIcon.Question) _
                 = Windows.Forms.DialogResult.Yes Then

            btncapture.Enabled = True
            Dim iDateFormat As Integer
            AxVideoCap1.CaptureMode = False
            AxVideoCap1.Stop()
            iDateFormat = frmMain.AddVideo.cbodateformat.SelectedIndex
            AxVideoCap1.Rotate(frmMain.AddVideo.cborotate.SelectedIndex)
            If frmMain.AddVideo.chkinvertcolor.Checked Then
                AxVideoCap1.InvertColor(True)
            Else
                AxVideoCap1.InvertColor(False)
            End If
            ' check to make sure the file actually exists already
            ' and if so append the file name 
            ' move the file from the Local Drive to the server
            Dim path As String = captureFileNameLocal
            If File.Exists(path) Then
                If File.Exists(captureFileNameRemote) = False Then
                    System.IO.File.Move(captureFileNameLocal, captureFileNameRemote)
                Else
                    System.IO.File.Move(captureFileNameLocal, Replace(captureFileNameRemote, ".wmv", "_1.wmv"))
                End If
            Else
                MsgBox("Finish Failed, file does not exist.", MsgBoxStyle.Information, "File Does Not Exist")
            End If

            ' remove any spaces in the file name, reformat the date and add the file extension
            Dim fileName As String = txtTitle.Text.Replace(" ", "") & ("_") & txtDateRecorded.Text.Replace("/", "-") & ".wmv"
            ' email body message
            strBody  Removed to shorten message           
' send email verifying video has been published to the server
            SendMailMessage Removed to shorten message           

        Else
            ' reset the controls
            btncapture.Enabled = True
            Dim iDateFormat As Integer
            AxVideoCap1.CaptureMode = False
            AxVideoCap1.Stop()
            iDateFormat = frmMain.AddVideo.cbodateformat.SelectedIndex
            AxVideoCap1.Rotate(frmMain.AddVideo.cborotate.SelectedIndex)
            If frmMain.AddVideo.chkinvertcolor.Checked Then
                AxVideoCap1.InvertColor(True)
            Else
                AxVideoCap1.InvertColor(False)
            End If
        End If
        txtTitle.Clear()
        mtbCourse.Clear()
        txtEmailAddress.Clear()
        txtInstructor.Clear()
        txtDescription.Clear()
    End Sub
Any suggestions for getting the message box to not hang up.

Thanks
CoachBarker
 
Maybe you can do this:

VB.NET:
Dim result as DialogResult = MessageBox.Show("Do you want to publish to the server?", "Publish Video", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

If result = Windows.Forms.DialogResult.Yes then
' Place your code here
...

Hope this will help you.

Jah Bless!!!:D
 
Did it still hang-up? I also experienced that and I am using the same code as what you did during that time. When I changed it to the code on my previous post it didn't hang.

Sorry if I confused you.
 
It sounds as you have something else hanging your UI thread.
 
Back
Top