problem using lock statement in c#

  //create serial data
                BeginInvoke((Action)(()=>
                    {
                lock (measures)
                {
                    for (int i = 0; i < measures.Count; i++)
                    {
                        if (measures.Count >= 0.0 && measures.Count<=0.5)
                        {
                            double x = myCurveOne.Points.Count;
                            double y = measures[i];
                            myCurveOne.AddPoint(x, y);
                            myCurveOne.Line.Color = Color.Green;
                        }
                        else if (measures.Count>0.5 &&measures.Count<=0.6)
                        {
                            double x = myCurveTwo.Points.Count;
                            double y = measures[i];
                            myCurveTwo.AddPoint(x, y);
                            myCurveTwo.Line.Color = Color.Yellow;
                        }
                        else if (measures.Count > 0.6 && measures.Count <=0.7)
                        {
                            double x = myCurveThree.Points.Count;
                            double y = measures[i];
                            myCurveThree.AddPoint(x, y);
                            myCurveThree.Line.Color = Color.Red;
                        }
                        else
                            return;
                    }

can i use this multiple if-else statement inside the lock block statements.?

can i use this multiple if-else statement inside the lock block statements.?

You have my permission. I don't see that this has anything to do with an Arduino.

I don't know what measures is an instance of, but I am not aware of any class in C# that has a Count property that is anything other than an integer value.

think you mean this

BeginInvoke((Action)(()=>
                    {
                lock (measures)
                {
                    for (int i = 0; i < measures.Count; i++)
                    {
                        if (measures[i] <= 0 )
                        {
                          return;
                        }
                        else if (measures[i] <= 0.5)
                        {
                            double x = myCurveOne.Points.Count;
                            double y = measures[i];
                            myCurveOne.AddPoint(x, y);
                            myCurveOne.Line.Color = Color.Green;
                        }
                        else if (measures[i] <= 0.6)
                        {
                            double x = myCurveTwo.Points.Count;
                            double y = measures[i];
                            myCurveTwo.AddPoint(x, y);
                            myCurveTwo.Line.Color = Color.Yellow;
                        }
                        else if (measures[i] <= 0.7)
                        {
                            double x = myCurveThree.Points.Count;
                            double y = measures[i];
                            myCurveThree.AddPoint(x, y);
                            myCurveThree.Line.Color = Color.Red;
                        }
                        else  // measures[i] > 0.7
                            return;
                    }

robtillaart,

i am thinking like that..but for the value measure 0-5 im referring to the first if-else block statement.. n so on..does the code works on the condition that i have set on my original coding?

thanks...

does the code works on the condition that i have set on my original coding?

Don't know what you mean exactly, I have tried to rewrite the code to what you probably meant it should do.

in your code you use measure.Count not measure *[/color] *
I kept the conditions in the code semantically equal.