Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Event in my code block! Does the compiler wait till the event is done then continue compiling my code?

Posted on by 460

.......Some code....................

.......Some Code....................

......Event_Publisher is called(Rec)...           //Give Rec to a subscriber (By Value) and it will change the rec

.......Code waiting for the subscribers result.... //Now here would the code wait till event is completely done before its continue?.

.......Some Code............................................           

The reason why I am asking is that I want to make sure that when I Publish and event Navision will wait till this even is completed then it will continue? is this true?

*This post is locked for comments

  • Verified answer
    M.Zayed Profile Picture
    M.Zayed 460 on at
    RE: Event in my code block! Does the compiler wait till the event is done then continue compiling my code?

    It will work! the compiler will wait till the event subscribers are completely finished (Keep in mind that the if you have more than one Subscribers that they will be executed in an undefined order) and then it will continue with compiling the rest of the code.
    I have test it my self + I received a conformation from waldo :=)

    community.dynamics.com/.../117.hooks-pattern  

    Hope this info will be helpful to other developers.

    Best Regards,

    Zayed

  • M.Zayed Profile Picture
    M.Zayed 460 on at
    RE: Event in my code block! Does the compiler wait till the event is done then continue compiling my code?

    Hi Paolo,

    Are you talking about order of events only? or order of normal code and event?

    its a bout having an event in the middle of your code, would this event be executed first?

    What is confusing me is that when I tried it for the first time it wasn't executed in the order which I defined! BUT when I tried it for another 10 times it worked with the order which I define. really confusing :(

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event in my code block! Does the compiler wait till the event is done then continue compiling my code?

    execution order is not guaranteed

    nav-skills.com/.../nav2016-hooks-vs-events

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans