Documentation or tutorials on using Thread?

Hi, I’m very new to TinyCLR (and mostly new to C# and .NET) and am busily trying it out at the moment.

I’m trying to understand how to use Thread as I haven’t had a chance to explore threading in any environment yet. I can’t find any documentation or examples that show its use however (besides threaded Blink examples) - I feel like I must be looking in the wrong place for documentation on TinyCLR so if there is an obvious resource I’m missing I’d love to be pointed towards it.

With regards to Thread in particular, I can see the general premise from the Blink example is to create a new Thread object with the name of the function I want to run in it and call its Start() method. If my function has parameters, how would I pass these through though?

eg.

Say I have a function declared as private static void Blink(GpioPin led_n), how do I modify new Thread(Blink).Start(); to pass the GpioPin for the function to use?

Thanks!

I usually create a Class which holds some public fields (e.g. the GPIO Pin I want to use) which are set through parameters in the constructor or later by access from the Main thread.
Then either in the Constructor or a public Start method of this Class I create a Thread and start this thread. In the new thread I can access the fields of the Class.

Thanks, this was a helpful suggestion.

try something like this:

Thread testThread = new Thread(() => Mymethod(param1, param2));
testThread.Start();