Callbacks in C#

后端 未结 5 1423
孤独总比滥情好
孤独总比滥情好 2020-12-28 17:52

I want to have a library that will have a function in it that accepts an object for it\'s parameter.

With this object I want to be able to call a specified function

5条回答
  •  情歌与酒
    2020-12-28 18:31

    Is there a reason not to have your library provide a public event to be fired when the operation is complete? Then the caller could just register to handle the event and you don't have to worry about passing around objects or delegates.

    The object implementing an interface you have provided would work, but it seems to be more the Java approach than the .NET approach. Events seem a bit cleaner to me.

提交回复
热议问题