InvokeOnUiThread Python Example

I’m trying to run the r.RhinoApp.RunScript method to insert a block from an event handler. I am attempting to use r.RhinoApp.InvokeOnUiThread() function based off of other discussions I have seen in this way:

def insertblock(file):
r.RhinoApp.RunScript(’_-Insert File=Yes LinkMode=Link “’+file+’” Block 0 _Enter 0,0,0 1 0.0’,True)

#inside of the event handler:

However this makes the following error:
changedrange for loop TypeError(‘expected Delegate, got function’,)

Is there anyone who could explain how to go about this the right way? Or if there is an existing example to look at. Thanks!

So, it seems I have a habit of answering my own questions lately. This was my solution:

At the imports of the script:
from IronPython.Compiler import CallTarget0

For the function call:
delegate = CallTarget0(insertLinkedBlock)

It looks like what i’m looking for is actually CallTarget1 in order to pass the argument of the function, but I cant seem to find it in the imports. The solution I came up with was to pass the file name through the sc.sticky, which I have a feeling isn’t the best solution. If anyone knows how to improve on this solution let me know.