Exemplo n.º 1
0
        private void SaveToFileTimerTick(object state)
        {
            if (CurrentFilePath == null)
            {
                CurrentFilePath = FolderFilePath + DateTime.Now.ToString("yyyMMdd_hhmmss") + ".txt";
            }

            IsDataPointList1Active = !IsDataPointList1Active;

            lock (DataPointsFileLockObject)
            {
                if (!IsDataPointList1Active)
                {
                    lock (GeneratedDataPointsList1)
                    {
                        if (GeneratedDataPointsList1.Count != 0)
                        {
                            File.AppendAllText(CurrentFilePath, String.Join(Environment.NewLine, GeneratedDataPointsList1) + Environment.NewLine);
                            GeneratedDataPointsList1.Clear();
                        }
                    }
                }
                else
                {
                    lock (GeneratedDataPointsList2)
                    {
                        if (GeneratedDataPointsList2.Count != 0)
                        {
                            File.AppendAllText(CurrentFilePath, String.Join(Environment.NewLine, GeneratedDataPointsList2) + Environment.NewLine);
                            GeneratedDataPointsList2.Clear();
                        }
                    }
                }
            }
        }
Exemplo n.º 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();
         });
     }
 }
Exemplo n.º 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);
     }
 }