Search code examples
eventsanylogic

How do I cancel a dynamic event in Anylogic?


I have a model that uses dynamic events to schedule a change in the size of a resource pool based on Stuart's response this question For my application I want the model user to be able to cancel the upcoming Dynamic event by clicking a button as part of the UI but I am not sure how to implement this using the reset() function. Any help would be much appreciated.


Solution

  • you need to save the instance of the dynamic event:

    so let's imagine your dynamic event is called Dynamic you can trigger it with create_Dynamic();

    Create a variable of type Dynamic... let's call this variable x and then do

    x=create_Dynamic();
    

    with this you can just cancel the dynamic event by doing

    x.reset();
    

    But the point of using dynamic events is that every time you do create_Dynamic() an instance of this event is created that is used independently so you shouldn't need to cancel it.

    If you need to cancel an event, instead use a normal even triggered by user... then you can cancel it easily