Copy link to clipboard
Copied
I am running few functions using
LrFunctionContext.postAsyncTaskWithContext
All of them access and modify a variable. How can I make sure this variable is async safe.
Copy link to clipboard
Copied
LR tasks (including the main task) are non-preemptive -- only one task runs at a time, and tasks switch only when a yielding API call is invoked. Which calls are yielding aren't well documented, but generally any call that must be executed within an async task could potentially yield.
So you can be confident that in between a task's calls to yielding API calls, another task won't run behind the scenes.
See this post for more information about API calls that yield:
It's actually quite tricky to program a plugin correctly, especially if you use floating dialogs or background tasks that run while the user is interacting with the application.
[Use the blue reply button under the first post to ensure replies sort properly.]