public void WriteBuffer(double d1)
 {
     lock (DataBuffer1)
     {
         DataBuffer1.Add(d1);
         if (DataBuffer1.Count > MaxBufferSize)
         {
             DataBuffer1.RemoveAt(0);
         }
     }
 }
 public void WriteArrayToBuffer(double[] d1)
 {
     lock (DataBuffer1)
     {
         for (int i = 0; i < d1.Length - 1; i++)
         {
             DataBuffer1.Add(d1[i]);
             if (DataBuffer1.Count > MaxBufferSize)
             {
                 DataBuffer1.RemoveAt(0);
             }
         }
     }
 }
        void ReadBuffer()
        {
            lock (DataBuffer1)
            {
                // get the actual buffer size
                int actualBuffer = DataBuffer1.Count;

                if (actualBuffer > 0)
                {
                    // get the current buffer data
                    ExtractedBufferData1 = DataBuffer1.GetRange(0, actualBuffer);
                    DataBuffer1.Clear();
                }
            }
        }
        void ProcessReadBuffer()
        {
            Array.Resize(ref displayArray1, ExtractedBufferData1.Count);

            double lastY1 = 0;

            currentX -= xStepSize;

            if (currentX < 0)
            {
                currentX = 0;
            }
            // now we have to form a SKPoint array from this datalist
            //foreach (double y in ExtractedBufferData1)
            for (int arrayCounter = 0; arrayCounter < ExtractedBufferData1.Count; arrayCounter++)
            {
                lastY1 = ExtractedBufferData1[arrayCounter];

                AutoScaling(lastY1);

                displayArray1[arrayCounter].X = currentX;

                displayArray1[arrayCounter].Y = graphMain.CanvasSize.Height - ((float)lastY1 - GridYMin) * pixelsPerUnitY - offsetY * pixelsPerUnitY;



                currentX += xStepSize;
                if (currentX > graphMain.CanvasSize.Width)
                {
                    currentX  = 0;
                    ClearFlag = true;
                    break;
                }
            }

            // store the last coordinate
            DataBuffer1.Add(lastY1);

            // now draw this array
            graphMain.InvalidateVisual();
        }