# Force function to finish first

**URL:** <https://forums.unrealengine.com/t/force-function-to-finish-first/445084>\
**Category:** Blueprint\
**Tags:** order, unreal-engine, question, Blueprint\
**Created:** [March 11, 2019, 3:29pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084 "2019-03-11T15:29:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neVeRmind8837](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neVeRmind8837](https://forums.unrealengine.com/u/neVeRmind8837)\
**Post date:** [March 11, 2019, 3:29pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/1 "2019-03-11T15:29:57Z")

</div>

So I´m currently getting some errors and the only thing that would explain this is that the function gets called, but the execution pin instantly continues without waiting the function to be finished… Or am I missing something here? Do I really have to use event dispatchers so I can be sure the function has finished?

 ![271020-functionwait.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/e/05e5437c350399581cb5b2839938316fdb787f41.jpeg)

---

<div class="post-metadata">

**Author:** ![SavvyIndoorsman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SavvyIndoorsman](https://forums.unrealengine.com/u/SavvyIndoorsman)\
**Post date:** [March 11, 2019, 4:18pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/2 "2019-03-11T16:18:30Z")

</div>

Are you sure the function isn’t finishing before execution continues? Everything that runs on the main game thread gets processed in a straightforward and predictable order.

Is it possible your function is spawning worker threads somehow? Is it using operating system libraries to modify files, which may, in turn, be doing something with multi-threading?

What exactly does that `Cleanup Folder` function do? Maybe with more information, we can better help you identify the problem.

---

<div class="post-metadata">

**Author:** ![Crowley\_Caine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crowley\_Caine](https://forums.unrealengine.com/u/Crowley_Caine)\
**Post date:** [March 11, 2019, 5:22pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/3 "2019-03-11T17:22:24Z")

</div>

It’s because that’s not a function, it’s an event. A function is denoted by an “f” instead of an arrow.

When an event is triggered the event calculates seperate from the event chain that triggered it. It does not need to be completed for the original event chain to continue down its path. If you need calculations to finish before moving on, you either use a function, an event for moving on or a variable.

So in this case, end the execution event at Cleanup Folder. Add an event called “Continue” for example and plug that into the first branch in “Geometry”. At the end of Cleanup Folder add a call to that event.

Here’s a visual representation of that:

 ![271035-example03.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/7/8a7329df3f266f069188c583a85ee5d51795dcc2.png)

---

<div class="post-metadata">

**Author:** ![neVeRmind8837](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neVeRmind8837](https://forums.unrealengine.com/u/neVeRmind8837)\
**Post date:** [March 11, 2019, 7:30pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/4 "2019-03-11T19:30:01Z")

</div>

I guess this must be the problem. I´m working with the asset regestry and rename files inside of this function. Since it is used in the editor, not at runtime it is reallý difficult to debug. Thank you for pointing me in the right direction!

---

<div class="post-metadata">

**Author:** ![neVeRmind8837](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neVeRmind8837](https://forums.unrealengine.com/u/neVeRmind8837)\
**Post date:** [March 11, 2019, 7:52pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/5 "2019-03-11T19:52:22Z")

</div>

Actually it was a function. But you pointed me in the right direction here. If a function doesn´t have an output the “f” disappears and it is handeled as an event. I added an empty output to my function and now it gets executed first. I was never aware of this.

---

<div class="post-metadata">

**Author:** ![Crowley\_Caine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crowley\_Caine](https://forums.unrealengine.com/u/Crowley_Caine)\
**Post date:** [March 11, 2019, 7:54pm UTC](https://forums.unrealengine.com/t/force-function-to-finish-first/445084/6 "2019-03-11T19:54:24Z")

</div>

A return node should serve the exact same purpose. Either way, you have options.
