Hi,

I have 2 forms ('test' and 'frmStart') which communicate with each other through MSMQ messaging. Test opens frmStart, which sends a message back when it's loaded. The problem is that the message is only read by test once frmStart is closed. I know this because when the message is read, a msgBox pops up, and this pops up when frmStart closes.
Can anyone help me with this problem?


*** the load handler in frmStart ***
VB Code:
  1. ' The form is loaded, the labels are filled with texts from the message
  2.     Private Sub frmStart_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.         Try
  4.             ' request info
  5.             fd.sType = "request"
  6.             fd.sLabel = "licenseInfo"
  7.             submit(sReturnProcessID)
  8.  
  9.             sProcessID = sFormProcessID
  10.             thMonitorMessageQueue.Start()
  11.  
  12.             'communicator = sender
  13.             Me.cbAccept.Checked = False
  14.             bShutdown = True
  15.         Catch ex As Exception
  16.             ErrorSystem.cfHandleError(ex)
  17.         End Try
  18.     End Sub

*** the submit sub ***
VB Code:
  1. ' Function to submit a message to the queue
  2.     Public Sub submit(ByVal recieverMessageID As String)
  3.         Try
  4.             ' A new message is made
  5.             Dim msgContent As New Assimilator.SDK.Communicator.Messages.MSMQCOntent
  6.             ' the message is given a new ID and a label
  7.             msgContent.msgID = recieverMessageID
  8.             msgContent.msgProcessID = recieverMessageID
  9.             msgContent.msgLabel = fd.sLabel
  10.             ' The message type is given as a string.
  11.             msgContent.msgType = fd.sType
  12.  
  13.             ' The ArrayLists with the parameters.
  14.             msgContent.msgFieldNames = New ArrayList
  15.             msgContent.msgFieldValues = New ArrayList
  16.  
  17.             ' All the parameters are put into the message.
  18.             If bParameters Then
  19.                 For iCounter As Integer = 0 To alNames.Count - 1
  20.                     msgContent.msgFieldNames.Add(alNames(iCounter))
  21.                 Next
  22.                 For iCounter As Integer = 0 To alValues.Count - 1
  23.                     msgContent.msgFieldValues.Add(alValues(iCounter))
  24.                 Next
  25.             End If
  26.             ' The message is submitted
  27.             msg.Submit(msgContent)
  28.         Catch ex As Exception
  29.             Assimilator.SDK.ErrorHandler.ErrorSystem.cfHandleError(ex)
  30.         End Try
  31.     End Sub

*** msgEvent handler in test ***
VB Code:
  1. Private Sub MsgEventHandler(ByVal msgContent As Assimilator.SDK.Communicator.Messages.MSMQCOntent) Handles msg.msgEvent
  2.         Try
  3.             Me.Show()
  4.             Select Case msgContent.msgType
  5.                 Case "result"
  6.                     ' Code to simulate Communicator opening / bringing form to front
  7.                     frm = New frm
  8.                     fd.sForm = msgContent.msgFieldValues(0)
  9.                     Select Case fd.sForm.ToLower 'msgContent.msgProcessID
  10.                         Case "frmstart"
  11.                             frm = New frmStart
  12.                         Case Else
  13.                             ' If no correct formName is given, the user gets this messageBox.
  14.                             MsgBox("Sorry, an error has occured. The right form could not be loaded. --> test.vb <--")
  15.                     End Select
  16.                     frm.sReturnProcessID = sProcessID
  17.                     Me.DialogResult = DialogResult.OK
  18.                 Case "request"
  19.                     MsgBox("request recieved")
  20.                     Me.DialogResult = DialogResult.OK
  21.             End Select
  22.             ' Code to populate request message with info of objects on screen
  23.         Catch ex As Exception
  24.             ErrorSystem.cfHandleError(ex)
  25.         End Try

*** frmStart closes ***
VB Code:
  1. ' This happens when the window closes.
  2.     Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _
  3.     Handles MyBase.Closing
  4.         Try
  5.             bShutdown = True
  6.         Catch ex As Exception
  7.             ErrorSystem.cfHandleError(ex)
  8.         End Try
  9.     End Sub