BrickPi.Brick.SetupSensors C# (CSharp) Method

SetupSensors() public method

Setup sensors. Don't use this function if the brick is started, only when not started
public SetupSensors ( ) : Task
return Task
        public async Task<bool> SetupSensors()
        {
            bool retval = true;   
            for(int idxArduino = 0; idxArduino<2; idxArduino++)
            {
                bool needsetup = false;
                for (int i=0; i<2; i++)
                {
                    int port = idxArduino * 2 + i;
                    if (prevType[port] != (int)brickPi.Sensor[port].Type)
                    {
                        needsetup = true;
                        prevType[port] = (int)brickPi.Sensor[port].Type;
                    }
                }
                if (needsetup)
                {
                    if (!isThreadRunning)
                        ThreadPool.RunAsync(async (iasyn) =>
                        {
                            bool ret = await BrickPiSetupSensors(idxArduino);
                            retval &= ret;
                        }, WorkItemPriority.High).AsTask().Wait();
                    else
                    {
                        bool ret = await BrickPiSetupSensors(idxArduino);
                        retval &= ret;
                    }
                }
            }
            return retval;
        }