zoukankan      html  css  js  c++  java
  • c#.net 计时器

    第一步,用WPF (.NET Framework),添加个TextBox,简单设置属性。

    第二步,贴代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Windows.Threading; //添加Threading类
    
    namespace ClockSample
    {
    
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                DispatcherTimer ClockOut = new DispatcherTimer(); // 类的实例化--设置对象(实例成员)
                ClockOut.Interval = TimeSpan.FromSeconds(1); //设置属性
                ClockOut.Tick += ClockOut_Tick;// 链接事件处理器
                ClockOut.Start(); 
            }
    
            private void ClockOut_Tick(object sender, EventArgs e)
            {
                this.ClockBox.Text = DateTime.Now.ToString();
            }
        }
    }
    

     

    心得:初识类的使用方法。 

  • 相关阅读:
    less中遇到的一些特殊的写法
    观察者模式
    发布订阅模式
    javascript中的函数
    关于js中this的理解和作用
    [Oracle]Oracle镜像安装及使用教程
    log4net日志配置
    过滤器
    .net core 处理 中文乱码
    Fromform
  • 原文地址:https://www.cnblogs.com/cnafzyx/p/11827016.html
Copyright © 2011-2022 走看看