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));
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...
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.
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,
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...