Ejemplo n.º 1
0
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     WaveDrawer.AddEventData(new EventData()
     {
         TimeStamp   = DateTime.Now.AddSeconds(-10),
         Description = DateTime.Now.ToLongDateString(),
         Detail      = DateTime.Now.Ticks + ""
     });
 }
Ejemplo n.º 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            WaveDrawer.AddLine(line1);
            Dispatcher x = Dispatcher.CurrentDispatcher;//取得当前工作线程

            //另开线程工作
            System.Threading.ThreadStart start = () =>
            {
                //工作函数
                var data = new DataPoint[250];

                for (int i = 0; i < 250; i++)
                {
                    data[i] = new DataPoint();
                }

                var begTime = DateTime.Now;

                for (int count = 0; count < 60; ++count)
                {
                    for (int i = 0; i < 250; i++)
                    {
                        data[i].RawData = i;
                    }


                    //异步更新界面
                    x.BeginInvoke(new Action(() =>
                    {
                        WaveDrawer.AddAndShowPoints(line1, data);
                    }), DispatcherPriority.Normal);


                    x.BeginInvoke(new Action(() =>
                    {
                        WaveDrawer.AddEventData(new EventData()
                        {
                            TimeStamp   = begTime.AddSeconds(count - 0.5),
                            Description = DateTime.Now.ToLongDateString(),
                            Detail      = DateTime.Now.Ticks + ""
                        });
                    }), DispatcherPriority.Normal);


                    Thread.Sleep(1000);
                }
            };

            new System.Threading.Thread(start).Start(); //启动线程

            //Task task = Task.Run(() =>
            //{
            //    for (int count = 0; count < 1000; ++count)
            //    {
            //        var data = new DataPoint[200];
            //        for (int i = 0; i < 200; i++)
            //        {
            //            data[i] = new DataPoint()
            //            {
            //                DataTag = null,
            //                RawData = i
            //            };
            //        }

            //        WaveDrawer.AddPoints(data);

            //        Thread.Sleep(100);
            //    }
            //});

            //task.Wait();

            return;

            //var data = new DataPoint[200];
            //for (int i = 0; i < 200; i++)
            //{
            //    data[i] = new DataPoint()
            //    {
            //        DataTag = null,
            //        RawData = i
            //    };
            //}

            //WaveDrawer.AddPoints(data);
            //WaveDrawer.DrawAxisYUnit(10, 5);
        }