09-19-2008 07:43 AM
How do i Catch error in parallel running thread?
I get error in my sequence running as a parallel thread but am not able to catch it. Rather the seq editor hangs.
I came to know about the cause of system halt by unit testing the sequence and removing parallel thread option.
09-22-2008 01:09 AM
Hi ,
The problem is that in order for an execution to break, all threads must be between steps. In other words, the execution cannot break while one of its threads is calling a module. It must wait for the module to return.
There is, however, a way around this. Using the TestStand API property Thread.ExternallySuspended, you can tell the TestStand engine to treat the thread that is running your code module as if it were an already suspended thread. When a thread is externally suspended, TestStand no longer requires it to be between steps in order for the execution to break.
The way you use the property, Thread.ExternallySuspended, is by setting it to True before the code in your module starts running and then set it to False immediately before returning from your module. You can get a reference to the Thread object from the Sequence Context (i.e. SequenceContext.Thread).
Note: If you set the property Thread.ExternallySuspended to False while the execution is at a breakpoint, the code module will block on the call to set the property until the execution in TestStand continues.
It is recommended to use the Thread.ExternallySuspended property within code modules that perform a lengthy operation or wait an indeterminate period of time (e.g. show a dialog box, have an internal while loop). For more information on Thread.ExternallySuspended, refer to the TestStand API Help section on this property.
I have attached an example link here below for better understanding -
http://sine.ni.com/devzone/cda/epd/p/id/3417
Thanks ,
Pranchal Srivastava ,
Application Engineer ,
NI
09-22-2008 04:04 PM
Shwets,
Please see this forum post: http://forums.ni.com/ni/board/message?board.id=330&message.id=20875#M20875 for an example that will handle an error that occurs in an independent thread.