public class Class1 { static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer(); static int alarmCounter = 1; static bool exitFlag = false;
// This is the method to run when the timer is raised. private static void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { myTimer.Stop();
// Displays a message box asking whether to continue running the timer. if(MessageBox.Show("Continue running?", "Count is: " + alarmCounter, MessageBoxButtons.YesNo) == DialogResult.Yes) { // Restarts the timer and increments the counter. alarmCounter +=1; myTimer.Enabled = true; } else { // Stops the timer. exitFlag = true; } }
public static int Main() { /* Adds the event and the event handler for the method that will process the timer event to the timer. */ myTimer.Tick += new EventHandler(TimerEventProcessor);
// Sets the timer interval to 5 seconds. myTimer.Interval = 5000; myTimer.Start();
// Runs the timer, and raises the event. while(exitFlag == false) { // Processes all the events in the queue. Application.DoEvents(); } return 0; } }
javascript脚本: var sh=setInterval("test1()",1000) function test1() { var online=document.Form1.hid_online.value; var outline=document.Form1.hid_outline.value; window.location.href("User_List.aspx?online="+online+"&outline="+outline+"&"+Math.random()); //刷新本页 或者触发一个按钮: obj=document.getElementById(buttonname); focus(obj); obj.click(); }
{
this.timer1.Interval=1000;
this.timer1.Enabled=true;
} private void timer1_Tick(object sender, System.EventArgs e)
{
this.Text=System.DateTime.Now.ToString();
}
static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
static int alarmCounter = 1;
static bool exitFlag = false;
// This is the method to run when the timer is raised.
private static void TimerEventProcessor(Object myObject,
EventArgs myEventArgs) {
myTimer.Stop();
// Displays a message box asking whether to continue running the timer.
if(MessageBox.Show("Continue running?", "Count is: " + alarmCounter,
MessageBoxButtons.YesNo) == DialogResult.Yes) {
// Restarts the timer and increments the counter.
alarmCounter +=1;
myTimer.Enabled = true;
}
else {
// Stops the timer.
exitFlag = true;
}
}
public static int Main() {
/* Adds the event and the event handler for the method that will
process the timer event to the timer. */
myTimer.Tick += new EventHandler(TimerEventProcessor);
// Sets the timer interval to 5 seconds.
myTimer.Interval = 5000;
myTimer.Start();
// Runs the timer, and raises the event.
while(exitFlag == false) {
// Processes all the events in the queue.
Application.DoEvents();
}
return 0;
}
}
var sh=setInterval("test1()",1000)
function test1()
{
var online=document.Form1.hid_online.value;
var outline=document.Form1.hid_outline.value;
window.location.href("User_List.aspx?online="+online+"&outline="+outline+"&"+Math.random()); //刷新本页
或者触发一个按钮:
obj=document.getElementById(buttonname);
focus(obj);
obj.click();
}