I have two listeners for event but according to documentation, "the order in which listeners execute is not defined". I want to check whether one callback has executed before the next without having that callback generate it's own event. Is there a way of doing this?
For example:
event: PayDay
listener callbacks: UpdateBankAccount, GoShopping
How can I ensure that UpdateBankAccount has ocurred before GoShopping?
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
If you implement the event provider yourself, it is possible to track which event listeners were fired before a specific callback.
You can implement a daughter class of event.EventData (I called it TrackableEventData here)
then you can add functionality for callbacks to subscribe once they are finished so that subsequent callbacks can check wheter a specific callback was fired already.
I made a class with the event PayDay (PayDayClass) this class will raise the PayDay event and send a copy of TrackableEventData in stead of the usual event.EventData that is generated by default (when you don't send anything particular).
The last class has both callbacks - UpdateBankAccount and GoShopping (I assume you have different classes for those callbacks but it doesn't matter for the sake of the example)
when the callbacks happen in the expected order, everything is fine, but when the order is wrong, an exception is thrown by the GoShopping callback.
SEE COMPLETE ANSWER CLICK THE LINK
Comments
Post a Comment