When to use callbacks instead of events in c#?

后端 未结 8 1669
春和景丽
春和景丽 2020-12-13 09:20

Forgive me if this a stupid question, I admit I haven\'t thought about it much.

But when would you favour using a callback (i.e, passing in a Func or Action), as oppo

8条回答
  •  自闭症患者
    2020-12-13 09:56

    I would use Func or Action when I am going to call the function once or use a Lambda expression.

    Events can be registered more than once which sometimes is ideal. With a callback, one has to implement a registration system for the callbacks if you want multiple.

提交回复
热议问题