# asyncUpdater example

**URL:** <https://forum.juce.com/t/asyncupdater-example/27356>\
**Category:** General JUCE discussion\
**Created:** [April 22, 2018, 3:08pm UTC](https://forum.juce.com/t/asyncupdater-example/27356 "2018-04-22T15:08:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicknamen](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@Nicknamen](https://forum.juce.com/u/Nicknamen)\
**Post date:** [April 22, 2018, 3:08pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/1 "2018-04-22T15:08:17Z")

</div>

Hi,

is there anywhere I can find an example of how to run a function asynchronously? I need to update a message being displayed on the screen while some processes are running but I cannot find any example anywhere.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [April 22, 2018, 3:10pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/2 "2018-04-22T15:10:55Z")

</div>

You could simply use the static function MessageManager::callAsync with a lambda, but you have to be very careful that the involved objects do not get destroyed before the lambda gets a chance to get executed.

---

<div class="post-metadata">

**Author:** ![Nicknamen](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@Nicknamen](https://forum.juce.com/u/Nicknamen)\
**Post date:** [April 22, 2018, 3:18pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/3 "2018-04-22T15:18:33Z")

</div>

```
MessageManager::callAsync([&]()
{
     message.set("Writing file...");

     repaint();
});

```

Something like this?  
It gets executed at the end of the calling function anyway

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [April 22, 2018, 3:22pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/4 "2018-04-22T15:22:15Z")

</div>

Well, it obviously doesn’t help if your processing/calculations happen in the GUI thread…(There really isn’t any clean and easy solution for that. You will have to change your processing to happen in another thread to be able to get GUI updates.)

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [April 22, 2018, 3:26pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/5 "2018-04-22T15:26:16Z")

</div>

Have a look at [ThreadPoolJob](https://docs.juce.com/develop/classThreadPoolJob.html) or [TimeSliceThread](https://docs.juce.com/develop/classTimeSliceThread.html) to do the work in the background.

HTH

---

<div class="post-metadata">

**Author:** ![Nicknamen](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@Nicknamen](https://forum.juce.com/u/Nicknamen)\
**Post date:** [April 22, 2018, 3:27pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/6 "2018-04-22T15:27:31Z")

</div>

Ok, thanks!

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [April 22, 2018, 3:31pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/7 "2018-04-22T15:31:10Z")

</div>

I wanted to link a great talk at the last JUCE meetup about that topic about 2 weeks ago, but googling to Dave Rowland… too many country songs on youtube 😉

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [April 22, 2018, 7:09pm UTC](https://forum.juce.com/t/asyncupdater-example/27356/8 "2018-04-22T19:09:34Z")

</div>

You can find the video to that talk here… [https://skillsmatter.com/skillscasts/11632-audio-developers-meet-up-april](https://skillsmatter.com/skillscasts/11632-audio-developers-meet-up-april)

and the corresponding repo here… [https://github.com/drowaudio/presentations/tree/master/Audio%20Developer%20Meetup%20April%202018](https://github.com/drowaudio/presentations/tree/master/Audio%20Developer%20Meetup%20April%202018)

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 23, 2019, 2:48am UTC](https://forum.juce.com/t/asyncupdater-example/27356/9 "2019-04-23T02:48:46Z")

</div>

I am absolute newbie with async functions. I try to understand `AsyncUpdater`. Looking for examples and background theory if it’s available.
