10-21-2020 07:27 AM
I want to run a TestStand sequence via .NET API in C#. I'm currently doing as follows:
Engine tsEngine = new Engine();
SequenceFile testSequenceFile = tsEngine.GetSequenceFileEx(pathToMySequence);
SequenceFile processModelSequenceFile = tsEngine.GetSequenceFileEx("MyProcessModel", GetSeqFileOptions.GetSeqFile_FindFile, TypeConflictHandlerTypes.ConflictHandler_Error);
Execution tsExecution = tsEngine .NewExecution(testSequenceFile, "MainSequence", processModelSequenceFile, false, 0);
var result = tsExecution.WaitForEndEx(1000);
Everything works fine, and WaitForEndEx returns true.
How can I wait for execution end in an async way? If I run WaitForEndEx in a separate Task it always time outs (example next line).
Task.Run(() => tsExecution.WaitForEndEx(1000));
Thanks.
10-22-2020 04:30 AM
Update: I tried to spawn tasks in several different ways, including a single task performing engine start sequence load and execution start, I also tried to execute the sequence via Dispatcher.CurrentDispatcher.Invoke thinking that it had to be run in the UI thread, but with no luck.
It seems that NewExecution and related WaitForEndEx can't be run in a separate Task.
Anyone could confirm or negate?
I'd really like to avoid to "import" in my GUI a complete TS UI just to silently run test sequences...
01-28-2021 05:24 AM
Hi! Have you looked at this document at NI. It describes how to Execute a TestStand sequence asynchronously. As I understood your initial question was regarding that.
02-03-2021 09:02 AM
Hi vardanium,
thanks for your answer, but how should it be related to my question?
I'm speaking about "C# async await for Execution.WaitForEndEx", I posted C# code, and you're linking me a knowledge base about using TestStand editor...
I need to use TS Dotnet API.
Thank you and have a nice day.
07-22-2021 09:11 AM
Hi Andrea,
Your request might solved, (at least I hope so) but I just hit on your topic and was wondering if you could give me a hint for a proper task synchronization.
Thanks in advance,
Br
Oliver
07-26-2021 01:21 AM
Ciao Oliver,
unfortunately no, I've not been able to solve my issue. In the end I wrote my minimal test executive all in C#, and forgot about TestStand...
Good luck,
Andrea