The best overloaded method match for System.Threading.Timer.Timer() has some invalid arguments

前端 未结 3 1824
时光取名叫无心
时光取名叫无心 2021-01-18 10:00

I\'m making a console application that must call a certain method in timed intervals.

I\'ve searched for that and found that the System.Threading.Timer

3条回答
  •  失恋的感觉
    2021-01-18 10:52

    TimerCallback delegate (first argument of the Timer constructor you use) takes one argument (state) of type object.

    All you have to do it to add parameter to the test method

    public static void test(object state)
    {
        Console.WriteLine("test");
    }
    

    And the issue will be resolved.

提交回复
热议问题