From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling the runTimeErrorAction result from DisplayRunTimeErrorDialogEx

Solved!
Go to solution

Hi,

 

I'm trying to replace the RunTime Error dialog with a customized dialog. The customized dialog will have the same options as the original dialog and some additional stuff. I attached an event handler to ApplicationMgr.BreakOnRunTimeError event but I don't know what's the correct way to mimic the behavior for the runTimeErrorAction.

 

I'm currently doing this:

 

var frameID = 0;
var sequenceContext = e.initiatingThread.GetSequenceContext(0, out frameID);

 

NationalInstruments.TestStand.Interop.API.RTEOptions.RTEOption_Continue:
  sequenceContext.SequenceErrorMessage = message;
  sequenceContext.SequenceErrorOccurred = true;
  sequenceContext.ErrorReported = true;
  sequenceContext.GotoCleanup = true;

  This makes the execution goes to cleanup and the sequence file will show Passed. The original behavior makes the execution shows Error.

 

NationalInstruments.TestStand.Interop.API.RTEOptions.RTEOption_Ignore:

  Do nothing

 

NationalInstruments.TestStand.Interop.API.RTEOptions.RTEOption_Retry:
  sequenceContext.NextStepIndex = sequenceContext.StepIndex;

  This has no effect.

 

NationalInstruments.TestStand.Interop.API.RTEOptions.RTEOption_Abort:
  e.exec.Abort();

  This is working fine.

 

Anyone can help with this?

0 Kudos
Message 1 of 4
(2,914 Views)

If you are handling the BreakOnRunTimeError event, you don't need to write the code to do these things, the ApplicationMgr does them for you. You just need to set the showDialog parameter to false so the ApplicationMgr won't show its dialog and set execution.RTEOptionForThisExecution to whichever option you want it to implement.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 4
(2,905 Views)
Solution
Accepted by ng chee meng

In looking at this more carefully, it appears that the BreakOnRunTimeError event does not work the way I thought it did (and probably not the way it was intended). Setting execution.RTEOptionForThisExecution has the side-effect of keeping the dialog from ever being displayed again. I've reported this issue for further consideration. To workaround this issue, the easiest thing you can do is to handle the AfterUIMessageEvent and reset RTEOptionForThisExecution back to RTEOption_ShowDialog, similar to the following:

 

        private void axApplicationMgr_AfterUIMessageEvent(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_AfterUIMessageEventEvent e)
        {
            if (e.uiMsg.Event == UIMessageCodes.UIMsg_BreakOnRunTimeError)
            {
                e.uiMsg.Execution.RTEOptionForThisExecution = RTEOptions.RTEOption_ShowDialog;
            }
        }

Your BreakOnRunTimeError handler would look something like the following:

 

        private void axApplicationMgr_BreakOnRunTimeError(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_BreakOnRunTimeErrorEvent e)
        {
            DisplayMyDialog(...);
            e.breakExecution = mydialogsbreakexecutionsetting;
            e.showDialog = false; // Don't show the application manager's dialog
            e.exec.RTEOptionForThisExecution = mydialogsrteoption;
        }

Hope this helps,

-Doug

0 Kudos
Message 3 of 4
(2,897 Views)

It's working. Thanks 🙂

0 Kudos
Message 4 of 4
(2,887 Views)