コード例 #1
0
 private void AddPointsToGraphTimerTick(object state)
 {
     if (App.Current != null)
     {
         App.Current.Dispatcher.Invoke((System.Action) delegate
         {
             IsNewDataPointList1Active = !IsNewDataPointList1Active;
             if (!IsNewDataPointList1Active)
             {
                 lock (NewDataPointsList1)
                 {
                     LineDataPoints.AddRange(NewDataPointsList1);
                     NewDataPointsList1.Clear();
                 }
             }
             else
             {
                 lock (NewDataPointsList2)
                 {
                     LineDataPoints.AddRange(NewDataPointsList2);
                     NewDataPointsList2.Clear();
                 }
             }
         });
     }
 }
コード例 #2
0
 private void UnloadDataFromAllLists()
 {
     if (App.Current != null)
     {
         App.Current.Dispatcher.Invoke((System.Action) delegate
         {
             LineDataPoints.Clear();
             GeneratedDataPointsList1.Clear();
             GeneratedDataPointsList2.Clear();
             NewDataPointsList1.Clear();
             NewDataPointsList2.Clear();
         });
     }
 }
コード例 #3
0
 private void FomulaThread()
 {
     while (ManualResetEvent.WaitOne())
     {
         double y = Math.Sin(X);
         X += 0.01;
         if (IsDataPointList1Active)
         {
             lock (GeneratedDataPointsList1)
             {
                 GeneratedDataPointsList1.Add(new DataPoint(X, y));
                 if (IsNewDataPointList1Active)
                 {
                     NewDataPointsList1.Add(new DataPoint(X, y));
                 }
                 else
                 {
                     NewDataPointsList2.Add(new DataPoint(X, y));
                 }
             }
         }
         else
         {
             lock (GeneratedDataPointsList2)
             {
                 GeneratedDataPointsList2.Add(new DataPoint(X, y));
                 if (IsNewDataPointList1Active)
                 {
                     NewDataPointsList1.Add(new DataPoint(X, y));
                 }
                 else
                 {
                     NewDataPointsList2.Add(new DataPoint(X, y));
                 }
             }
         }
         Thread.Sleep(1);
     }
 }