コード例 #1
0
        private static Task NetObjectToTask(NetObject no)
        {
            var taskObject = no.ToObject();

            if (taskObject is Task task)
            {
                return(task);
            }
            return(null);
        }
コード例 #2
0
        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");
        }