資源簡介
本例將常用的幾種計時方式都進行了嘗試,并通過測試了解了各種計時的應用區別,方便后續的應用!代碼里還有詳細的解釋說明,方便使用!
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Diagnostics;//提供一組方法和屬性,可用于準確地測量運行時間只有引用后Stopwatch類才能使用
using?System.Threading;//創建和控制線程,設置其優先級并獲取其狀態。
namespace?秒表計時器
{
????public?partial?class?Form1?:?Form
????{
????????private?BackgroundWorker?demoBGWorker?=?new?BackgroundWorker();
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????timer1.Enabled?=?false;
????????????timer1.Interval?=?500;
????????}
????????int?timerDrawI?=?0;
????????float?timerDrawF?=?0;
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????timerDrawI++;
????????????timerDrawF?=?timerDrawI?/?2;
????????????textBox_ms.Text?=?Convert.ToString(timerDrawI);
????????????textBox_sec.Text?=?Conver
- 上一篇:二維碼生成解析工具
- 下一篇:S7協議連接(C#版)
評論
共有 條評論