可以呼叫同一個Function,
但是不能使用同一個Timer.
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;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
private bool btn1Click = false;
private bool btn2Click = false;
private int btn1time = 0, btn2time = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
if(btn1Click)
{
btn1time ++;
btn1label.Text = btn1time.ToString();
}
if(btn2Click)
{
btn2time ++ ;
btn2label.Text = btn2time.ToString();
}
}
private void btn1_Click(object sender, EventArgs e)
{
btn1Click = true;
timer1.Enabled = true;
}
private void btn2_Click(object sender, EventArgs e)
{
btn2Click = true;
timer1.Enabled = true;
}
}
}