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


C# System.Windows.Forms.Timer.Dispose方法代码示例

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


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

示例1: DelayExecuteWin

 /// <summary>
 /// 延迟执行
 /// </summary>
 /// <param name="delayTime">延迟时间,毫秒</param>
 /// <param name="execute">执行函数</param>
 public static void DelayExecuteWin(int delayTime, Action execute)
 {
     var time = new System.Windows.Forms.Timer();
     time.Interval = delayTime;
     time.Tick += (s, e) =>
     {
         time.Enabled = false;
         if (execute != null)
         {
             execute();
         }
         time.Dispose();
     };
     time.Enabled = true;
 }
开发者ID:zdx2015,项目名称:Zeniths,代码行数:20,代码来源:TimerHelper.cs

示例2: Run

        /// <summary>
        /// Initializes WinForms and starts the message loop.  Blocks until <see cref="Terminate"/> is called.
        /// </summary>
        public void Run()
        {
        	_guiThread = Thread.CurrentThread;

        	Application.CurrentUICultureChanged += Application_CurrentUICultureChanged;

            // this must be called before any GUI objects are created - otherwise we get problems with icons not showing up
            System.Windows.Forms.Application.EnableVisualStyles();

            // create a timer to raise the Started event from the message pump
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 100;
            timer.Tick += delegate(object sender, EventArgs args)
            {
                // immediately disable the timer so we don't get a second Tick
                timer.Dispose();
                EventsHelper.Fire(_started, this, EventArgs.Empty);
            };
            timer.Enabled = true;

            // start the message pump
            System.Windows.Forms.Application.Run();
        }
开发者ID:nhannd,项目名称:Xian,代码行数:26,代码来源:GuiToolkit.cs

示例3: Timeout

 public void Timeout(float time, System.Action action)
 {
     System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
     t.Tick += new EventHandler((o, s) => { t.Dispose(); action(); });
     t.Interval = (int)(time * 1000);
     t.Enabled = true;
 }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:7,代码来源:Manager.cs


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