multithreading - C# use SerialPort in Thread loop -


i have issue, want use serial port in thread loop. can't because thread not static , threadloop static. know how ?

my code (simplified) :

public static void threadloop()     {         // code simplified in example...                  {             sendtoarduino(coordinate, r, g, b)          } while (thread.currentthread.isalive);     }      private static void sendtoarduino(string coordinate, byte r, byte g, byte b)     {         currentport.writeline(coordinate);         currentport.write(new byte[] {r, g, b}, 0, 4);     } 

thanks in advance.


Comments