private static Task NetObjectToTask(NetObject no) { var taskObject = no.ToObject(); if (taskObject is Task task) { return(task); } return(null); }
private static IValue AwaitInternal(NetObject no) { var taskObject = no.ToObject(); if (taskObject is Task <IValue> taskResult) { if (taskResult.Status == TaskStatus.Created) { taskResult.Start(); } taskResult.Wait(); return(taskResult.Result); } else if (taskObject is Task task) { if (task.Status == TaskStatus.Created) { task.Start(); } task.Wait(); return(Value.Nil); } throw new Exception("Only functions or taks can be used with await"); }