Delegates and Callbacks

后端 未结 4 962
有刺的猬
有刺的猬 2021-02-03 14:07

Does the term callback in the context of delegates mean ,\"a delegate delegating it works to another delegate inorder to finish some task\" ?

Example :(

4条回答
  •  故里飘歌
    2021-02-03 14:37

    A callback is basically a delegate passed into a procedure which that procedure will "call back" at some appropriate point. For example, in asynchronous calls such as WebRequest.BeginGetResponse or a WCF BeginXxx operation, you'd pass an AsyncCallback. The worker will "call back" whatever method you pass in as the AsyncCallback, in this case when it's finished to let you know that it's finished and to obtain the result.

    An event handler could be considered another example. For example, when you attach a handler to a Click event, the button will "call back" to that handler when the click occurs.

提交回复
热议问题