private void DrawingFlow()
        {
            LinesFlow.Clear();
            App.Current?.Dispatcher?.Invoke(() =>
            {
                double cFx1 = 1400 / (Breathes[CurrentItem].ExpirationX.Max());
                double cFx2 = (Breathes[CurrentItem].InspirationY.Select(i => i.Flow).Max() > Breathes[CurrentItem].ExpirationY.Select(i => i.Flow).Max()) ? 100 / Breathes[CurrentItem].InspirationY.Select(i => i.Flow).Max() : 100 / Breathes[CurrentItem].ExpirationY.Select(i => i.Flow).Max();
                for (int i = 0; i < Breathes[CurrentItem].InspirationX.Count() - 1; i++)
                {
                    LinesFlow.Add(new Line
                    {
                        FromX = Breathes[CurrentItem].InspirationX[i],
                        FromY = Breathes[CurrentItem].InspirationY[i].Flow,
                        From  = new System.Windows.Point(Breathes[CurrentItem].InspirationX[i] * cFx1, Breathes[CurrentItem].InspirationY[i].Flow * -cFx2 + 100),
                        ToX   = Breathes[CurrentItem].InspirationX[i + 1],
                        ToY   = Breathes[CurrentItem].InspirationY[i + 1].Flow,
                        To    = new System.Windows.Point(Breathes[CurrentItem].InspirationX[i + 1] * cFx1, Breathes[CurrentItem].InspirationY[i + 1].Flow * -cFx2 + 100)
                    });
                }

                for (int i = 0; i < Breathes[CurrentItem].ExpirationX.Count() - 1; i++)
                {
                    LinesFlow.Add(new Line
                    {
                        FromX = Breathes[CurrentItem].ExpirationX[i],
                        FromY = Breathes[CurrentItem].ExpirationY[i].Flow,
                        From  = new System.Windows.Point(Breathes[CurrentItem].ExpirationX[i] * cFx1, Breathes[CurrentItem].ExpirationY[i].Flow * cFx2 + 100),
                        ToX   = Breathes[CurrentItem].ExpirationX[i + 1],
                        ToY   = Breathes[CurrentItem].ExpirationY[i + 1].Flow,
                        To    = new System.Windows.Point(Breathes[CurrentItem].ExpirationX[i + 1] * cFx1, Breathes[CurrentItem].ExpirationY[i + 1].Flow * cFx2 + 100)
                    });
                }
            });
        }
 private void Drawing()
 {
     while (true)
     {
         Thread.Sleep(100);
         App.Current?.Dispatcher?.Invoke(() => // <--- HERE
         {
             LinesFlow.Add(new Line
             {
                 From = new System.Windows.Point(_k, _k * 2),
                 To   = new System.Windows.Point(_k++, _k * 2)
             });
         });
     }
 }