国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

WinForm實現程序一段時間不運行自動關閉的方法

2020-01-24 01:29:24
字體:
來源:轉載
供稿:網友

本文實例講述了WinForm實現程序一段時間不運行自動關閉的方法。分享給大家供大家參考。具體實現方法如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Net;using System.IO;using System.Security.Cryptography.X509Certificates;using System.Net.Security;namespace DemoDataGridView{ public partial class Form3 : Form, IMessageFilter {  private int m_WaitMinute = 0;  System.Windows.Forms.Timer MyTimer;  public Form3()  {   InitializeComponent();   MyTimer = new Timer();   MyTimer.Interval = 1000;   MyTimer.Tick += new EventHandler(MyTimer_Tick);   Application.Idle += new EventHandler(Application_Idle);  }  void MyTimer_Tick(object sender, EventArgs e)  {   if (m_WaitMinute < 60)   {    MyTimer.Enabled = true;    MyTimer.Interval = 10000; //10秒    m_WaitMinute += 1;    // this.Opacity = 1.0 - Convert.ToDouble(m_WaitMinute / 60.0);   }   else   {    MyTimer.Enabled = false;   }  }  void Application_Idle(object sender, EventArgs e)  {   if (m_WaitMinute == 0)   {    System.IO.File.WriteAllText("D://1.txt", DateTime.Now.ToString());    MyTimer.Start();   }   else   {    if (m_WaitMinute >= 6)    {     System.IO.File.WriteAllText("D://2.txt", DateTime.Now.ToString());     this.Close();    }   }  }  public bool PreFilterMessage(ref Message m)  {   if (m_WaitMinute != 0)   {    m_WaitMinute = 0;    MyTimer.Enabled = false;    return true;   }   return false;  } }}

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 道孚县| 福清市| 衡东县| 特克斯县| 略阳县| 繁昌县| 诸城市| 奉贤区| 葵青区| 金山区| 平陆县| 麦盖提县| 罗甸县| 互助| 乌拉特后旗| 会东县| 凤翔县| 错那县| 鄯善县| 镇坪县| 霍邱县| 密山市| 社会| 曲水县| 新田县| 满洲里市| 红桥区| 福安市| 宁南县| 石嘴山市| 武安市| 漳浦县| 富源县| 石景山区| 崇文区| 赤城县| 高要市| 永嘉县| 乐亭县| 句容市| 宜宾市|