Thread\'s checking

Find and share HowTos to various installations / configurations!
Search

Post Reply
6 posts • Page 1 of 1
SergE
Posts: 8
Joined: Wed Oct 12, 2016 8:23 am

Thread\'s checking

Post 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.

SergE
Posts: 8
Joined: Wed Oct 12, 2016 8:23 am

Re: Thread\'s checking

Post by SergE »

Is this a feature of WinCCOA? I am bewildered :(

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Thread\'s checking

Post 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

SergE
Posts: 8
Joined: Wed Oct 12, 2016 8:23 am

Re: Thread\'s checking

Post 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()?

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Thread\'s checking

Post 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.

SergE
Posts: 8
Joined: Wed Oct 12, 2016 8:23 am

Re: Thread\'s checking

Post 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.

Post Reply
6 posts • Page 1 of 1