c# 时间间隔统计 简单的问题,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/28 23:13:34
遇到难题了,请 高人们帮忙写个程序片段,大概内容功能如下;

窗体上有一个 按钮,一个LABLE;

主窗体From1 的CS文件内容: 点击按钮以后 ,调用Time中的计时函数,开始计时,统计时间间隔次数,即每过一定的时间 LABLE上的数字加一;

Time.cs 内容:是一个计时器 隔一定的时间 自动重新计时,

应该很菜鸟的问题吧
我想不通怎么把cs报时的事件传给From1,所以请高手们帮我写下哦~
合起来写我会

希望能用到using System.Timers

分开成两个CS 文件写的话 time.cs 中没有 lable 的 定义,不知道怎么写了

Timers.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace WinFormEmpty
{
class MyTimers
{
Label label = null;
int resetTime = 0;//重置时间
private int idx = 0;
private delegate void SetLabelDeletegate(string value);
System.Timers.Timer t = new System.Timers.Timer();
public MyTimers(Label label,int resetParam)
{
this.label = label;
this.resetTime = resetParam;
}
/// <summary>
///
/// </summary>
/// <param name="interval">时间间隔</param>
public void TimersOption(int interval)
{
t.Interval = interval;
t.Elapsed += new ElapsedEventHandler(tmr_Elapsed);
t.Start();