Does anyone know of design patterns or best practices for dealing with chains of asynchronous callbacks?

Does anyone know of design patterns or best practices for dealing with chains of asynchronous callbacks?

We need to replace all of the currently blocking ShowModal calls in our app with Show/OnClose type blocks instead. I'm planning on switching to anonymous methods for most, like FMX's non-blocking ShowModal, but that doesn't seem like it's going to scaling well in cases where there's a series of possibly optional dialogs that might depend on previous dialog's responses. Memory management and exception handling look like they're going to be hairy too since try..finally/except won't work, and the callbacks don't have the caller's stack to unwind to.

Comments

  1. Edwin Yip I am using OTL's interface for inspiration. This question is more about what kind of guidelines are good for managing a chain of Parallel.Async calls that depend on each other. I'll probably just need to dive deep into design patterns that the .NET community has developed around their async support, but I was hoping there were some obvious ones I could start with. The most obvious answers are classes or finite state machines that wrap the logic, but this is hitting hundreds of places in our code, so the more I can simplify things the better.

    ReplyDelete
  2. Maybe define a helper class that uses window messages to communicate with the other parts of the software? You can pass an Anno. method (for OnClose event) to it too. Something like this: gist.github.com - Idea for https://plus.google.com/u/0/115543678481226143222/posts/46dTfcuVVLP?cfem=1

    ReplyDelete

Post a Comment