Pass extra parameters to an event handler?

后端 未结 8 976
执笔经年
执笔经年 2020-11-22 15:31

Let\'s say I want to pass some extra data when assigning an event handler. Consider the following code:

private void s         


        
8条回答
  •  天命终不由人
    2020-11-22 15:54

    Here is my one-line solution that pass extra parameters to a timer handler.

    private void OnFailed(uint errorCode, string message)
    {
        ThreadPoolTimer.CreateTimer((timer) => {
        UI.ErrorMessage = string.Format("Error: 0x{0:X} {1}", errorCode, message);
        }, System.TimeSpan.FromMilliseconds(100));
    }
    

提交回复
热议问题