我如何使用 Timer.tick 事件处理程序发送 2 个整数参数

本文关键字:整数 参数 程序 何使用 Timer tick 事件处理 | 更新日期: 2023-09-27 17:56:52

我有一个带有 Timer.tick 事件的构造函数,

public PlayMe(int rows, int cols)
{
    this.rows = rows;
    this.cols = cols;
    delay = new Timer();
    delay.Enabled = false;
    delay.Interval = 550;
    delay.Tick += delay_Tick;
    restart = new Timer();
    restart.Enabled = false;
    restart.Interval = 550;
    restart.Tick += restart_Tick(rows,cols);

如何在 Timer.Tick 方法中同时触发行和 cols 参数?

void restart_Tick(int rows, int cols)
{
    restart.Stop();
    if (gameOver && lblLose.Visible)
    {
        clearBoard();
        createBoard(rows,cols);
    }
    if (gameOver && lblWin.Visible)
    {
        for (int i = 0; i < 5; i++)
        {
            clearBoard();

我如何使用 Timer.tick 事件处理程序发送 2 个整数参数

重写:

restart.Tick += (object s, EventArgs a) => restart_Tick(s, a, rows, cols);

和方法:

  void restart_Tick(object sender, EventArgs e,int rows, int cols)