当前位置: 首页>>代码示例>>C#>>正文


C# DispatcherTimer.Start方法代码示例

本文整理汇总了C#中System.Windows.Threading.DispatcherTimer.Start方法的典型用法代码示例。如果您正苦于以下问题:C# DispatcherTimer.Start方法的具体用法?C# DispatcherTimer.Start怎么用?C# DispatcherTimer.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Threading.DispatcherTimer的用法示例。


在下文中一共展示了DispatcherTimer.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindow

        public MainWindow()
        {
            InitializeComponent();


            DispatcherTimer timer = new DispatcherTimer();
            Random rnd = new Random();
            timer.Interval = TimeSpan.FromSeconds(1.0);
            timer.Tick += (s, e) =>
                {
                    TestTimer++;

                    TestBackground = new SolidColorBrush(Color.FromRgb(
                        (byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255)));

                    FocusedElement = Keyboard.FocusedElement == null ? string.Empty : Keyboard.FocusedElement.ToString();
                    //Debug.WriteLine(string.Format("ActiveContent = {0}", dockManager.ActiveContent));

                };
            timer.Start();

            this.DataContext = this;

            winFormsHost.Child = new UserControl1();

        }
开发者ID:VoronFX,项目名称:AvalonDock.Themes.VS2013,代码行数:26,代码来源:MainWindow.xaml.cs

示例2: PlatformWpf

        public PlatformWpf()
            : base(null, true)
        {
            var app = new Application ();
            var slCanvas = new Canvas ();
            var win = new Window
            {
                Title = Title,
                Width = Width,
                Height = Height,
                Content = slCanvas
            };

            var cirrusCanvas = new CirrusCanvas(slCanvas, Width, Height);
            MainCanvas = cirrusCanvas;

            win.Show ();

            EntryPoint.Invoke (null, null);

            var timer = new DispatcherTimer ();
            timer.Tick += runDelegate;
            timer.Interval = TimeSpan.FromMilliseconds (1);

            timer.Start ();
            app.Run ();
        }
开发者ID:chkn,项目名称:cirrus,代码行数:27,代码来源:Bootstrap.cs

示例3: ViewModel

        public ViewModel()
        {
            mgt = new ManagementClass("Win32_Processor");
            procs = mgt.GetInstances();

            CPU = new ObservableCollection<Model>();
            timer = new DispatcherTimer();
            random = new Random();
            time = DateTime.Now;
            cpuCounter = new PerformanceCounter();
            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";
            ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            ProcessorID = GetProcessorID();
            processes = Process.GetProcesses();
            Processes = processes.Length;
            MaximumSpeed = GetMaxClockSpeed();
            LogicalProcessors = GetNumberOfLogicalProcessors();
            Cores = GetNumberOfCores();
            L2Cache = GetL2CacheSize();
            L3Cache = GetL3CacheSize();
            foreach (ManagementObject item in procs)
                L1Cache = ((UInt32)item.Properties["L2CacheSize"].Value / 2).ToString() + " KB";

            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick += timer_Tick;
            timer.Start();
            for (int i = 0; i < 60; i++)
            {
                CPU.Add(new Model(time, 0,0));
                time = time.AddSeconds(1);
            }
        }
开发者ID:jcw-,项目名称:sparrowtoolkit,代码行数:34,代码来源:ViewModel.cs

示例4: Subscribe

        private static void Subscribe(DataGrid dataGrid)
        {
            if (infoDict.ContainsKey(dataGrid))
                return;

            var timer = new DispatcherTimer(DispatcherPriority.Background);
            var handler = new NotifyCollectionChangedEventHandler((sender, eventArgs) => timer.Start());

            infoDict.Add(dataGrid, new DataGridInfo(handler, timer));

            timer.Tick += (sender, args) => ScrollToEnd(dataGrid);
            ((INotifyCollectionChanged)dataGrid.Items).CollectionChanged += handler;
            
            timer.Start();
        }
开发者ID:mikel785,项目名称:Logazmic,代码行数:15,代码来源:DataGridBehavior.cs

示例5: OverviewViewModel

        public OverviewViewModel()
        {
            today = DateTime.Today;

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMinutes(1);
            timer.Tick += (sender, args) =>
                {
                    if (DateTime.Today <= today) return;

                    today = DateTime.Today;
                    UpdateHeaders();
                };
            timer.Start();

            ItemSelectionChangedCommand = new ActionCommand(ItemSelectionChanged);
            LinkCommand = new ActionCommand(ShowLink);
            LoadedCommand = new ActionCommand(Loaded);
            TodayCommand = new ActionCommand(_ => Show(MenuRepository.GetTodaysMenu()));
            ExpandAllCommand = new ActionCommand(_ => SetAllExpansion(true));
            CollapseAllCommand = new ActionCommand(_ =>
                {
                    SetAllSelection(false);
                    SetAllExpansion(false);
                });
        }
开发者ID:lycilph,项目名称:Projects,代码行数:26,代码来源:OverviewViewModel.cs

示例6: StartTimer

 private void StartTimer()
 {
     DispatcherTimer dt = new DispatcherTimer();
     dt.Interval = new TimeSpan(0, 0, 1);
     dt.Tick += timer_Tick;
     dt.Start();
 }
开发者ID:KingDada,项目名称:AddAddressToTomTom,代码行数:7,代码来源:TimerWindow.xaml.cs

示例7: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            Stream iconResource = Assembly.GetExecutingAssembly().GetManifestResourceStream("DateTimeConverter.Images.Clock.ico");
            this.Icon = BitmapFrame.Create(iconResource);

            this.menuItemExit.Click += MenuItemExit_Click;
            this.menuItemClear.Click += MenuItemClear_Click;
            this.menuItemGithub.Click += MenuItemGithub_Click;
            this.menuItemAbout.Click += MenuItemAbout_Click;

            this.dateTimeOnRemoteComputer.Value = DateTime.Now;
            this.dateTimeOnRemoteComputer.Format = Xceed.Wpf.Toolkit.DateTimeFormat.Custom;
            this.dateTimeOnRemoteComputer.FormatString = this.dateTimeFormatStr;
            this.dateTimeOnRemoteComputer.ValueChanged += DateTimeOnRemoteComputer_ValueChanged;

            this.dateTimeOfEvent.Value = DateTime.Now;
            this.dateTimeOfEvent.Format = Xceed.Wpf.Toolkit.DateTimeFormat.Custom;
            this.dateTimeOfEvent.FormatString = this.dateTimeFormatStr;
            this.dateTimeOfEvent.ValueChanged += DateTimeOfEvent_ValueChanged;

            this.UpdateCurrentTime();
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(DispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
开发者ID:alonrotem,项目名称:DateTimeConverter,代码行数:28,代码来源:MainWindow.xaml.cs

示例8: startclock

 private void startclock()
 {
     DispatcherTimer timer = new DispatcherTimer();
     timer.Interval = TimeSpan.FromSeconds(1);
     timer.Tick += tickevent;
     timer.Start();
 }
开发者ID:RineshRamadhin,项目名称:Smart-Mirror-App,代码行数:7,代码来源:MainWindow.xaml.cs

示例9: MainWindow

 public MainWindow()
 {
     //img = new Image();
     //img.Source = new BitmapImage(new Uri(String.Format("pack://application:,,,/niespodzianka;component/Images/Banana/1.png"), UriKind.RelativeOrAbsolute));
     //img.Source = new BitmapImage(new Uri("pack://application:,,,/niespodzianka;component/Properties/Resources/cat1.png", UriKind.RelativeOrAbsolute));
     //img.Source = new BitmapImage(new Uri("pack://application:,,,/cat1", UriKind.RelativeOrAbsolute));
     //BitmapImage b = new BitmapImage(new Uri(@"/cat1.png", UriKind.Relative));
     //img.Source = new BitmapImage(new Uri(String.Format("pack://application:,,,/pwsg6;component/Images/{0}/{1}.png", animations[i],j), UriKind.RelativeOrAbsolute));
     wynik = 0;
     zolte = 0;
     godziny = 0;
     minuty = 0;
     sekundy = 0;
     tiki = 0;
     rozmiary = new int[] { 8, 8, 7, 9, 5, 7 };
     SizeX = 10;
     SizeY = 10;
     ksztalty = new Border[SizeY, SizeX];
     timer = new DispatcherTimer();
     timer.Interval = new TimeSpan(150 * 10000);
     timer.Tick += timer_Tick;
     InitializeComponent();
     timerLabel.Content = "Czas: 0:0:0";
     wynikLabel.Content = "Wynik: 0";
     RobPlansze();
     timer.Start();
 }
开发者ID:padzikm,项目名称:WindowsGraphicalProgramming,代码行数:27,代码来源:MainWindow.xaml.cs

示例10: GitViewModel

		private GitViewModel()
		{
			timer = new DispatcherTimer();
			timer.Interval = TimeSpan.FromMilliseconds(100);
			timer.Tick += new EventHandler(timer_Tick);
			timer.Start();
		}
开发者ID:jasondeering,项目名称:Git-Source-Control-Provider,代码行数:7,代码来源:GitViewModel.cs

示例11: ViewModel

 public ViewModel()
 {
     Current = this;
     PrimarySerial.NewMessageReceived += PrimarySerial_NewMessageReceived;
     if (IsDebugMode)
     {
         DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
         dt.Tick += delegate
         {
             if (!IsRandomizerEnabled || Calibrator.ActiveCalibrationSub == null)
                 return;
             double val = 0;
             switch (Calibrator.CalibrationTarget)
             {
                 case CalibrationTarget.Pump:
                     weight = weight + rnd.NextDouble() * (double)Calibrator.ActiveCalibrationSub.Setpoint / 500000;
                     val = weight;
                     break;
                 case CalibrationTarget.Stirrer:
                     val = (0.7 * rnd.NextDouble() + 0.3) * (double)Calibrator.ActiveCalibrationSub.Setpoint / 60;
                     break;
             }
             if (Calibrator.ActiveCalibrationSub != null)
                 Calibrator.ActiveCalibrationSub.AddPoint(new DataPoint(DateTime.Now, val));
         };
         dt.Start();
     }
 }
开发者ID:igemsoftware,项目名称:Aachen_2015,代码行数:28,代码来源:ViewModel.cs

示例12: UserControl_Loaded

 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     myTimer=new DispatcherTimer();
     myTimer.Tick += new EventHandler(myTimer_Tick);
     myTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
     myTimer.Start();
 }
开发者ID:zvrkan5,项目名称:DotNetSiemensPLCToolBoxLibrary,代码行数:7,代码来源:SubwindowService.xaml.cs

示例13: InitializeTimer

 private void InitializeTimer()
 {
     _timer = new DispatcherTimer();
     _timer.Tick += (sender, args) => this.Close();
     _timer.Interval = new TimeSpan(0, 0, 5);
     _timer.Start();
 }
开发者ID:8515008,项目名称:LenovoWiFi,代码行数:7,代码来源:NotificationWindow.xaml.cs

示例14: UserControl_Loaded

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!m_LoadedOnce)
            {
                try
                {
                    _Schiphol_ACXS_ScriptDataSet = ((_Schiphol_ACXS_ScriptDataSet)(this.FindResource("_Schiphol_ACXS_ScriptDataSet")));
                    // Load data into the table Container. You can modify this code as needed.
                    _Schiphol_ACXS_ScriptDataSetContainerTableAdapter = new _Schiphol_ACXS_ScriptDataSetTableAdapters.ContainerTableAdapter();

                    _Schiphol_ACXS_ScriptDataSetContainerTableAdapter.Connection.ConnectionString = m_sysConfig.ContainerDBConnectionString;
                    _Schiphol_ACXS_ScriptDataSetContainerTableAdapter.ClearBeforeFill = true;
                    _Schiphol_ACXS_ScriptDataSetContainerTableAdapter.Fill(_Schiphol_ACXS_ScriptDataSet.Container);
                    System.Windows.Data.CollectionViewSource containerViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("containerViewSource")));
                    containerViewSource.View.MoveCurrentToFirst();

                    updateDataGrid1Timer = new DispatcherTimer();
                    updateDataGrid1Timer.Interval = new TimeSpan(0, 0, 0, 0, m_sysConfig.ContainerRefreshPeriodmsecs);
                    updateDataGrid1Timer.Tick += new EventHandler(updateDataGrid1Timer_Tick);
                    updateDataGrid1Timer.Start();
                    m_LoadedOnce = true;
                }
                catch { }
            }
        }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:25,代码来源:UserControl1.xaml.cs

示例15: MainPage

        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            app.str_Uri = null;

            #region 计时
            txtb_Time = new TextBlock();
            Canvas.SetLeft(txtb_Time, 350);
            Canvas.SetTop(txtb_Time, 0);
            Carrier.Children.Add(txtb_Time);
            this.txtb_Time.Text = count.ToString();//开始时为00:00:00
            this.timer.Tick += Timer_Tick;//时间控件timer,事件Tick,类似线程
            this.timer.Interval = TimeSpan.FromMilliseconds(100);//每100毫秒变化一次
            StartTime = DateTime.UtcNow;
            this.timer.Start();//控件timer开始计时,类似线程开始
            #endregion

            #region 判断是否游戏结束
            dispatcherTimerChecked = new DispatcherTimer();
            dispatcherTimerChecked.Tick += new EventHandler(dispatcherTimerChecked_Tick);
            dispatcherTimerChecked.Interval = TimeSpan.FromMilliseconds(50);
            dispatcherTimerChecked.Start();
            #endregion
        }
开发者ID:GhostSoar,项目名称:JigsawPuzzle,代码行数:26,代码来源:MainPage.xaml.cs


注:本文中的System.Windows.Threading.DispatcherTimer.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。