Return Awaitable Task in Zero Touch

Is there a way to return a value using
Task and Await functions using zero touch?
I am not able to get it to work because it gives a generic output. I can’t find any other time this was addressed.

Hi @Marcello , you can try with this way set test1 use await to do something and method is private or internal, method test2 to show in dynamo and execute method1

private static async Task<double> Test(double number)
  {
      await Task.Delay(5000);
      var result = Math.Sqrt(number);
      return result;
  }
        
  public static double Test2(double number)
  {
      double result = Test(number).Result;
      return result;
  }


Another way but I don’t recommand

public static double Test(double number)
        {
            Task.Delay(5000).Wait();
            var result = Math.Sqrt(number);
            return result;
        }
1 Like

thx that is a good workaround

but I really want to know why dynamo is not able to return an awaitable operator within one method?
Does
System.Threading.Tasks.Task{System.Int32}
Look like the correct output?

Hi @Marcello , Unfortunately, like you, I am also waiting for this development support generic class from Autodesk internal developers, I also ask for generic classes but there are probably many limitations on code architecture. There are things that are also difficult for developers to decide in an already created framework in many year.

This is unfortunate I use awaitable functions all the time

My suggestion is to use wait functions in a library and you create a new class to call and return the result with dynamo package.