加一个Timer,在Tick事件中触发你自己的事件,这样间隔时间由你自己控制。
解决方案 »
- gridControl1 DevExpress.XtraGrid.GridControl 关于DV控件的输入验证?
- 对MQ有研究的请帮忙
- 帮帮。。我在一个事件中触发另一个事件,出现这种提示。。。。
- 请问为什么要用接口再c#里
- 请教高手,我的DataGrid在点了编辑之后EditCommand事件没有被触发,而是返回了一个空白表
- 一个英语问题,篮球中的“盖帽”因改怎样翻译?
- 如何当Form显示时,自动弹出Pocket PC的输入法,就是右下角的那个输入小键盘,并且切换为英文输入???????
- 要解决不同机子不同应用程序间通讯问题,看什么书好!
- 报表源的设置问题?
- Winform中IsMdiContainer的问题
- Crystal Report中及其郁闷的问题
- 怎样检测机器上(系统为win200)是否打上sp2或sp3等等
public FireEventArgs(string room, int ferocity) {
this.room = room;
this.ferocity = ferocity;
} // The fire event will have two pieces of information--
// 1) Where the fire is, and 2) how "ferocious" it is. public string room;
public int ferocity;} //end of class FireEventArgs
// Class with a function that creates the eventargs and initiates the event
public class FireAlarm { // Events are handled with delegates, so we must establish a FireEventHandler
// as a delegate: public delegate void FireEventHandler(object sender, FireEventArgs fe); // Now, create a public event "FireEvent" whose type is our FireEventHandler delegate. public event FireEventHandler FireEvent; // This will be the starting point of our event-- it will create FireEventArgs,
// and then raise the event, passing FireEventArgs. public void ActivateFireAlarm(string room, int ferocity) { FireEventArgs fireArgs = new FireEventArgs(room, ferocity);
// Now, raise the event by invoking the delegate. Pass in
// the object that initated the event (this) as well as FireEventArgs.
// The call must match the signature of FireEventHandler. FireEvent(this, fireArgs);
}
} // end of class FireAlarm
// Class which handles the eventclass FireHandlerClass { // Create a FireAlarm to handle and raise the fire events. public FireHandlerClass(FireAlarm fireAlarm) { // Add a delegate containing the ExtinguishFire function to the class'
// event so that when FireAlarm is raised, it will subsequently execute
// ExtinguishFire. fireAlarm.FireEvent += new FireAlarm.FireEventHandler(ExtinguishFire);
} // This is the function to be executed when a fire event is raised.
void ExtinguishFire(object sender, FireEventArgs fe) { Console.WriteLine("\nThe ExtinguishFire function was called by {0}.", sender.ToString()); // Now, act in response to the event. if (fe.ferocity < 2)
Console.WriteLine("This fire in the {0} is no problem. I'm going to pour some water on it.", fe.room);
else if (fe.ferocity < 5)
Console.WriteLine("I'm using FireExtinguisher to put out the fire in the {0}.", fe.room);
else
Console.WriteLine("The fire in the {0} is out of control. I'm calling the fire department!", fe.room);
}
} //end of class FireHandlerClasspublic class FireEventTest {
public static void Main () { // Create an instance of the class that will be firing an event. FireAlarm myFireAlarm = new FireAlarm();
// Create an instance of the class that will be handling the event. Note that
// it receives the class that will fire the event as a parameter. FireHandlerClass myFireHandler = new FireHandlerClass(myFireAlarm);
//use our class to raise a few events and watch them get handled
myFireAlarm.ActivateFireAlarm("Kitchen", 3);
myFireAlarm.ActivateFireAlarm("Study", 1);
myFireAlarm.ActivateFireAlarm("Porch", 5);
return; } //end of main} // end of FireEventTest