It assigns an async lambda to the Elapsed
event of timer
. You can understand the async lambda this way: first, the following is a lambda:
(sender, e) => HandleTimer()
this lambda calls HandleTimer
synchronously. Then we add an await to call HandleTimer
asynchronously:
(sender, e) => await HandleTimer()
but this won't work because to call something asynchronously you have to be asynchronous yourself, hence the async
keyword:
async (sender, e) => await HandleTimer()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…