zoukankan      html  css  js  c++  java
  • 程序退出时,显示程序运行时间

    关闭程序后,显示程序运行时间。代码如下:
    View Code
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 using System.Diagnostics;
    10 namespace time
    11 {
    12     public partial class Form1 : Form
    13     {
    14         public Form1()
    15         {
    16             InitializeComponent();
    17         }
    18         private Stopwatch stop= new Stopwatch();
    19         private void Form1_Load(object sender, EventArgs e)
    20         {
    21             stop.Start();
    22         }
    23 
    24         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    25         {
    26             DialogResult dr = MessageBox.Show("真的要退出?", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    27             if (dr == DialogResult.Yes)
    28             {
    29                 stop.Stop();
    30                 MessageBox.Show("程序共运行时间:" + stop.Elapsed.Seconds.ToString() + "");
    31                 e.Cancel = false;
    32             }
    33             else
    34             {
    35                 e.Cancel = true;
    36             }
    37         }
    38     }
    39 }
  • 相关阅读:
    solidworks中的一些标注尺寸的技巧
    SolidWorks 2-8草图绘制的一般过程
    SolidWorks 2-7 草图的约束【课程来自虎课网】
    SolidWorks 2-5 草图的编辑
    HTML 文本格式化实例--实体
    今天长进之redis的学习
    初步了解Quartz
    职场风云3
    内网穿透
    职场风云2
  • 原文地址:https://www.cnblogs.com/bymeet/p/close.html
Copyright © 2011-2022 走看看