algorithmic modeling for Rhino
I am now writing a grasshopper definition using C# component.
Basically I am executing an external script from GH, and wait until it finishes writing text files and read them from GH. In order to do that I am using async await method. The script editor shows syntax error when I try to run it, though the component can be run normally. However when other errors occur, I have to do some mighty changes to make it work properly(to be precise what I did is just copy and paste and everything runs properly. no script content is actually changed).
The error shows the method lacks await operators although I do have one in the later part of the script. As a result every time I open a new file the component shows error.
I am wondering why this error happens, one of my guess is the C# component is not fully compatible to the async await method. Am I right? Or there is a correct way of using this method?
Anyone has same problem before or any ideas?
Can you post your code? async and await do work in scripting components. You can't use await in the RunScript method since the signature is hardcoded and you need to add the async keyword, but you can use them in your methods under <Custom additional code>.
See the example below (I don't think there's a clean way to avoid calling ExpireSolution to update the result).
private void RunScript(object x, object y, ref object A)
if(result == null)
Sum(2, 2).ContinueWith(r =>
result = r.Result;
A = result;
// <Custom additional code>
async System.Threading.Tasks.Task<double> Sum(double a, double b)
return a + b;
// </Custom additional code>