문제

I have a constructor with a Timer.tick event,

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);

How I fire both rows and cols arguments inside the Timer.Tick method?

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();
도움이 되었습니까?

해결책

Rewrite:

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

And the method:

  void restart_Tick(object sender, EventArgs e,int rows, int cols)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top