Page 1 of 1
Thread\'s checking
Posted: Fri Feb 03, 2017 9:37 am
by SergE
Code: Select all
main()
{
...
int tid = startThread("thread1");
delay(0,5);
...
waitThread(tid); // !!!--->>> Output warning to logViewer: Invalid argument in function
// This understandable, after all, thread does not exist at this time.
...
}
void thread1()
{
}
Questions:
1. How i can squelch (suppress) the warning message after waitThread()?
or
2. How i can check existence of arbitrary thread, started in the script?
Thanks.
Re: Thread\'s checking
Posted: Tue Feb 07, 2017 8:21 am
by SergE
Is this a feature of WinCCOA? I am bewildered

Re: Thread\'s checking
Posted: Tue Feb 07, 2017 8:48 am
by mkoller
Currently there is no function to check for the existence of a thread.
Even if it would, since threads run "in parallel" there is no guarantee that the thread would still exist AFTER you called
some "threadExists" function.
What you probably can do in your script is using a semaphore.
Check the help at qthelp://wincc_oa/doc/ControlS_Z/Semaphorfunctions.htm
Re: Thread\'s checking
Posted: Tue Feb 07, 2017 9:06 am
by SergE
Thank you.
Even if it would, since threads run "in parallel" there is no guarantee that the thread would still exist AFTER you called
some "threadExists" function.
Yes, of course. I about this has not thought.
But, why warning message is issuing after waitThread()?
Re: Thread\'s checking
Posted: Tue Feb 07, 2017 9:18 am
by mkoller
Because you tried an operation on a non existing thread.
This is probably a point for discussion. We could just store the error in the thread and not print it ...
Still I hope you find a solution e.g. with the semaphore.
Re: Thread\'s checking
Posted: Tue Feb 07, 2017 9:45 am
by SergE
We could just store the error in the thread and not print it
I hoped this. Generally, i don't see any error in this situation. I need to wait thread end only. If it already terminated, i expected continuation of normal execution of main thread.
Still I hope you find a solution e.g. with the semaphore.
Yes, thank you.