Pass async Callback to Timer constructor

前端 未结 2 1328
太阳男子
太阳男子 2021-02-05 01:27

I have async callback, which is passed into Timer(from System.Threading) constructor :

private async Task HandleTimerCallback(object state)
{
    if (timer == nu         


        
2条回答
  •  情话喂你
    2021-02-05 01:57

    Is there any way to omit that o param in lambda?

    Sure, just define your event handler method as async void:

    private async void HandleTimerCallback(object state)
    

提交回复
热议问题