# Using a lambda function for invokeLater and invokeAsynchronous

**URL:** <https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526>\
**Category:** General Discussion\
**Tags:** scripting\
**Created:** [March 18, 2024, 11:28pm UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526 "2024-03-18T23:28:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![denny\_jimenez](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@denny\_jimenez](https://forum.inductiveautomation.com/u/denny_jimenez)\
**Post date:** [March 18, 2024, 11:28pm UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526/1 "2024-03-18T23:28:37Z")

</div>

Hello! Im trying to use a lambda function as a parameter to invokeLater and invokeAsynchronous. My code looks like this:

```auto
def executeWArgsAsync(funcName, *args, **kwargs):
	return system.util.invokeAsynchronous(lambda: funcName(*args,**kwargs))

```

The function executeWArgsAsync must run invokeAsynchronous with any function that I pass as a parameter to it.

Is there any problem expected to happen using this approach?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 18, 2024, 11:42pm UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526/2 "2024-03-18T23:42:42Z")

</div>

What version of Ignition are you using? `system.util.invokeAsynchronous` already supports passing args and kwargs in, and will transparently pass them to the inner function. So, I'm not sure what this wrapper function is adding unless you're on an older version lacking that support.

As for your question, it should work fine. You might consider using functools.partial to be more explicit about what you're doing, but they should be basically equivalent, functionally.

---

<div class="post-metadata">

**Author:** ![denny\_jimenez](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@denny\_jimenez](https://forum.inductiveautomation.com/u/denny_jimenez)\
**Post date:** [March 19, 2024, 12:27am UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526/3 "2024-03-19T00:27:52Z")

</div>

Im using 8.1.

So I should be able to use `system.util.invokeAsynchronous(funcName(*args, **kwargs))?`

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 19, 2024, 12:46am UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526/4 "2024-03-19T00:46:07Z")

</div>

Per the [manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-invokeAsynchronous) it should be `system.util.invokAsynchronous(func, *args, **kwargs)`

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 19, 2024, 2:09am UTC](https://forum.inductiveautomation.com/t/using-a-lambda-function-for-invokelater-and-invokeasynchronous/87526/5 "2024-03-19T02:09:44Z")

</div>

Pass your positional args in a sequence (list, tuple) and your named arguments in a mapping (dictionary). Handle them as normal args in your function.
