Main Site Documentation

Gadgeteer multi threading?


#1

Hi! I wanted to ask, Is it possible to have two processes run simultaneously on the spider board?

Since I’m using the glide library, and there I can use a progress bar but what use of progress bar if no other process is being performed?
How can I integrate some initialize function in this code for example?

       while (progressBar.Value < progressBar.MaxValue)
            {
                progressBar.Value += 5;
                progressBar.Invalidate();
                Thread.Sleep(100);
            }

#2

@ bioengproject -

    public partial class Program
    {
        Thread ColorCheckThread;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            ColorCheckThread = new Thread(RunColorCheck);
            ColorCheckThread.Start();
        }

        void RunColorCheck()
        {
            colorSense.LedEnabled = true;

            while (true)
            {
                //Do stuff here

                Thread.Sleep(100);
            }
        }
    }

#3

@ James - Thanks