New Task Concurrency API examples

I saw in the v3.8 SDK release notes that’s there’s a new task concurrency API. I’ve been looking at the tasks.h header file and it seems fairly well document but I was wondering if there’s any samples or recommended ways to use this? For example say I have a button that makes a web call, then based on the response wants to update the UI asynchronously this seems like it would be a perfect use case for this but I’m not 100% sure how to structure this.

Hi,

the API is very simple, just call

Tasks::schedule (Tasks::backgroundQueue (), [] () {  
    doSomethingInTheBackground ();
    Tasks::schedule (Tasks::mainQueue (), [] () {
        informSomethingOnTheMainThread ();
    };
});

You just have to make sure that your objects you need are alive while doing asynchronous calls.

2 Likes

This is perfect! Exactly what I was needing to finish a plugin we are working on. Thanks!