Home > front end >  Do event calls stop execution of the mthod that called it until the event is done?
Do event calls stop execution of the mthod that called it until the event is done?

Time:02-07

I have a save system I created that has two events, OnSaving and onl oading, in my OnDestroy method I'm calling the OnSaving event then after I'm running some code that requires that the game has fully saved, so my question is when an event is called, does the method that called the event wait until all subscribers have finished as if it was calling an event in the save class, or does it continue execution immediately?

CodePudding user response:

All events(like Action and others) are just delegates - “generic methods”. So when the event is invoked, what actually happens is just a call of all subscribers. Event invocation is atomic - all subscribed methods are called in the order they have subscribed. Simplifying all of this - you just calling multiple methods with one. And yes, after the event invocation all subscribers' complete execution is guaranteed.

  •  Tags:  
  • Related