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:
' The form is loaded, the labels are filled with texts from the message Private Sub frmStart_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try ' request info fd.sType = "request" fd.sLabel = "licenseInfo" submit(sReturnProcessID) sProcessID = sFormProcessID thMonitorMessageQueue.Start() 'communicator = sender Me.cbAccept.Checked = False bShutdown = True Catch ex As Exception ErrorSystem.cfHandleError(ex) End Try End Sub
*** the submit sub ***
VB Code:
' Function to submit a message to the queue Public Sub submit(ByVal recieverMessageID As String) Try ' A new message is made Dim msgContent As New Assimilator.SDK.Communicator.Messages.MSMQCOntent ' the message is given a new ID and a label msgContent.msgID = recieverMessageID msgContent.msgProcessID = recieverMessageID msgContent.msgLabel = fd.sLabel ' The message type is given as a string. msgContent.msgType = fd.sType ' The ArrayLists with the parameters. msgContent.msgFieldNames = New ArrayList msgContent.msgFieldValues = New ArrayList ' All the parameters are put into the message. If bParameters Then For iCounter As Integer = 0 To alNames.Count - 1 msgContent.msgFieldNames.Add(alNames(iCounter)) Next For iCounter As Integer = 0 To alValues.Count - 1 msgContent.msgFieldValues.Add(alValues(iCounter)) Next End If ' The message is submitted msg.Submit(msgContent) Catch ex As Exception Assimilator.SDK.ErrorHandler.ErrorSystem.cfHandleError(ex) End Try End Sub
*** msgEvent handler in test ***
VB Code:
Private Sub MsgEventHandler(ByVal msgContent As Assimilator.SDK.Communicator.Messages.MSMQCOntent) Handles msg.msgEvent Try Me.Show() Select Case msgContent.msgType Case "result" ' Code to simulate Communicator opening / bringing form to front frm = New frm fd.sForm = msgContent.msgFieldValues(0) Select Case fd.sForm.ToLower 'msgContent.msgProcessID Case "frmstart" frm = New frmStart Case Else ' If no correct formName is given, the user gets this messageBox. MsgBox("Sorry, an error has occured. The right form could not be loaded. --> test.vb <--") End Select frm.sReturnProcessID = sProcessID Me.DialogResult = DialogResult.OK Case "request" MsgBox("request recieved") Me.DialogResult = DialogResult.OK End Select ' Code to populate request message with info of objects on screen Catch ex As Exception ErrorSystem.cfHandleError(ex) End Try
*** frmStart closes ***
VB Code:
' This happens when the window closes. Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _ Handles MyBase.Closing Try bShutdown = True Catch ex As Exception ErrorSystem.cfHandleError(ex) End Try End Sub




Reply With Quote