right, you are never actually creating a new thread. you are only creating instances of the classes and call them from the main thread. so what you do is blocking vvvv forever every 3 seconds.
there are several threading patterns in C# which are not so easy to understand. a very good source to read is this online book: Threading in C# - Free E-book
it is not very easy to rewrite your example with threading and thread safe events. because you not only have to start a new thread, but you also want to send data back to the main thread via the Tick event every 3 seconds.
Tasks are more easy to handle async stuff in C# and definitely the first thing to look at. But they also do not handle the recurring events back to the main thread in an easy way.
depending on what you want to do, VL has a AsycTask and AsyncLoop region that do all the complicated threading stuff for you and you just have to fill out the functionality that you want to do asynchronously. check the AsyncTask example in the VL girlpower and the attached patch that does the same as you were trying to do in the C# code:
Hi all !
Thank you so much for your responses !!
I’ll check them out !
my final purpose is to catch events from the eyetracker Tobi EyeX (which is not handled by the actual node Eytracker.)
but first I need to understand how to deal with threads in plugin in vvvv.
all your links should help me, thanks !
I’ll post simples patches which demonstrate thread implementation in a vvvv plugin with a listen handler.
Merci merci !