I am using an API that contains callback methods. My program does some processing, calls method in the API and awaits the callback before continuing. Can someone tell me how that typically happens. Where a program needs to wait for something before continuing.
Wont just calling a method from with in a method automatically "wait" till the called method returns (or by "catching" the variable that method returns)? or is there something between the lines when we read "call back methods"..?
Hi, I'm not exactly sure of what the question is, but here goes:
Callbacks are usually used when a certain process needs to run on a seperate thread, or the process is not allowed blocking the calling thread. The call would normally spawn a new thread, or simply place the call in an event queue of sorts. Once the processing thread is finished, it will call the original thread (callback) notifying it of completion, possibly with a result.
It is the calling threads responsibility to either wait for the response, or continue processing, depending on the situation.