RobotStudio event

Handler on RapidData for GTPUMessageBox

Options
Hi,

I want to show a gtpumessagebox when the value of variable x = true. So I:
AddHandler bToHMI_StckDrpped.ValueChanged, AddressOf ShowMsgStackDrpped
    Sub ShowMsgStackDrpped(ByVal sender As Object, ByVal e As DataValueChangedEventArgs)

        If bToHMI_StckDrpped.Value.ToString = RTrue.Value.ToString Then
            MsgStackDrpped()
        End If
    End Sub
    Sub MsgStackDrpped()
        Dim Title As String = "Stack Dropped : Robot Requesting Action"
        Dim Message As String = "Please Select between 'RETRY' if you want to Continue Movement (False Drop information) OR 'CANCEL' if you want To Do the next scheduled Robot Task."
        Dim response As MsgBoxResult
        Dim rNum As RapidDomain.Num
        rNum.FillFromNum(2)
        response = MsgBox(Message, MsgBoxStyle.RetryCancel, Title)
        'GTPUMessageBox.Show(Me, Nothing, Message, Title, _
        '     System.Windows.Forms.MessageBoxIcon.Hand, System.Windows.Forms.MessageBoxButtons.RetryCancel)
        If response = MsgBoxResult.Retry Then
            rNum.FillFromNum(2)
            nFrmHMI_StckDrppedAnswr.Value = rNum
        Else
            rNum.FillFromNum(1)
            nFrmHMI_StckDrppedAnswr.Value = rNum
        End If
    End Sub

    Private Sub StckDrppedRC(ByVal sender As System.Object, ByVal Answer As MessageBoxEventArgs)

        If Answer.DialogResult = Windows.Forms.DialogResult.Retry Then
            rNum.FillFromNum(2)
            nFrmHMI_StckDrppedAnswr.Value = rNum
        Else
            rNum.FillFromNum(1)
            nFrmHMI_StckDrppedAnswr.Value = rNum
        End If

    End Sub

 receive a message error like a thread cannot be the parents of another threads.  So with the VC i tried with a standard msgbox and it works well.  So if its not possible to use a msgbox I will like to know how i can do to show a GTPUMessageBox just when a Rapiddata = TRUE?

Best Regards,

Martin

Comments

  • carlosmtz2000
    Options
    Hi Martin,
     

    The method ShowMsgStackDrpped is not executed by the UI thread. In order to make a change in the UI (in your case, a GTPUMessageBox), your code must be executed by the UI thread.

     

    You need to Invoke the UI thread in any control.

     

    Ex. C# .... this.Invoke( ....) <-- where "this" refers to the TpsForm

     

    BR

     
    Carlos Martinez
    ABB