I have a DLL that return all information asynchronous to several event handler. When I press a button I call a series of functions in the DLL, but the next function should not be called until the previous function has fired the event handler.
Button_Click_Handler() {
LCV.Load() // Returns immediately, Fires OnLoaded or OnError when done.
// Pause execution here and wait the for OnLoaded or OnError event to fire.
LCV.Read() // Returns immediately, Fires OnCard Or OnError when done.
// Pause execution here and wait the for OnCard or OnError event to fire.
LCV.Put(x) // Returns immediately, Fires OnPut Or OnError when done.
// Pause execution here and wait the for OnPut or OnError event to fire.
}
Is there a way to wait for an event to fire without having to attach an event handler and use signalling? To spread out the flow through all event handler would be very messy and not easy to follow. If the code was in the event handlers themself, it has to know "what mode" it is in and execute different code snippets. As I said, extremely messy.