A callback is a reference to a portion of executable code, that is passed as an argument to other code.
Using callback, for instance, a server program can notify to a caller when the requested operation ends. The callback paradigm can also be used instead of the Observer Design Pattern. In Microsoft .Net Framework, callbacks are implemented using delegates that provides type-safe function pointer.
A delegate is declared using the delegate key-word:
public delegate void OperationCallbackDelegate(int value);
After the delegate is declared it can be used as an argument of the method on the server class. When the elaboration ends, the server can notify the result to the client by invoking the callback delegate:
public void DoWork(OperationCallbackDelegate callback)
{
int val = 0;
// do something with variable "val"
// invoke the delegate and pass the result to the client
callback(val);
}
The client must pass as argument of the method of the server class a pointer to a function with the same signature of the delegate:
server.DoWork(this.ServerCallback);
public void ServerCallback(int value)
{
Console.WriteLine(value);
}

523046d1-772a-4b1a-a9de-7c17c3b00660|0|.0