Return issues with visual studio C++ PLM

I want to work with OpenCV to test what is possible in usage with PLCnext. The problem is that OpenCV is normally working with returns to open a camera or leaving the camara view for example.
I was making a working thread to make sure it wasn’t running in the real time cycle of the execute program. Below is the current logic of mine visible:

I already removed while loops, breaks and returns but it is still giving the following error:
image.pngHow could I prevent this issue. Is there a way to use return methods that doesnt effect the system?

I do see that in picture there is still a return but the same error comes when I remove that return.

Good afternoon
I’ve recreated your code in a worker thread and it compiles as I would expect. I am not able to upload and share the project here, so please contact us at support@phoenixcontact.nl so we can share the project files if you want.