请大家帮看下下面的代码。比如我现在想停掉Interval为2000,4000,8000的TIMER应该怎么写。using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace timerTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
AddTimer myAddTimer = new AddTimer((i + 1) * 1000);
}
}
} public class AddTimer
{
public AddTimer(int TimeInterval)
{
Timer myTimer = new Timer();
myTimer.Interval = TimeInterval;
myTimer.Tick+=new EventHandler(myTimer_Tick);
myTimer.Start();
} private void myTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show(e.ToString());
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace timerTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
AddTimer myAddTimer = new AddTimer((i + 1) * 1000);
}
}
} public class AddTimer
{
public AddTimer(int TimeInterval)
{
Timer myTimer = new Timer();
myTimer.Interval = TimeInterval;
myTimer.Tick+=new EventHandler(myTimer_Tick);
myTimer.Start();
} private void myTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show(e.ToString());
}
}
}
解决方案 »
- 如何解决MySQL Connector/NET执行查询语句卡住的问题
- C#窗体异步套接字
- tabControl显示在控件的左侧的时候,TABPAGE 的TEXT 属性就显示不出来了~~?
- 一个锁定Label控件的问题
- 专业.net技术群欢迎有志者加入,谢绝灌水。群号13433321
- 一个简单的问题
- Asp.net里面怎么用sql语句查询SQL Server里smalldatetime类型的字段?
- 如何使Directory.GetFiles()得到的文件列表是按照创建日期排序的?
- 请问,如何得到datagrid中某一个cell的对象的句柄?
- 完全采用.net技术制作的.net中文技术讨论社区开张了!!!
- 最棘手的问题,请各位位高手帮忙解决
- 最近玩某一网络游戏被欺负啊,不知用c#能不能写游戏外挂啊?
{
static private timers = new List<Timer>();
public AddTimer(int TimeInterval)
{
Timer myTimer = new Timer();
myTimer.Interval = TimeInterval;
myTimer.Tick+=new EventHandler(myTimer_Tick);
timers.add(myTimer);
myTimer.Start();
}private void myTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show(e.ToString());
}public void StopTimer(iny interval)
{
foreach(Timer t in timers)
{
if(t.Interval==interval)
t.Stop();
}
}
}
static private timers = new List<Timer>();
这句有问题
但是思路可以我自己修改可以了