Callback

Callback design pattern allows us to avoid "freezing" the rest of the application if a method takes too long to return. It is very useful if running computationally-expensive or time unpredictable methods. It does generally involve running in a separate thread/task.

  1. The solution involves creating IXCallback interface which contains method called whn the slow operation finishes running e.g. finish(.
  2. Add parameter of type XCallback to the slow operation
  3. Execute the body of the slow operation asynchronously (i.e. another thread/task, and call finish( to notify the caller

Leave Comment

Your email address will not be published.

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box