Ejemplo n.º 1
0
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null || args.Length == 0 || args[0] == null)
                return PType.Null.CreatePValue();

            var iargs = Call.FlattenArguments(sctx, args, 1);

            var retChan = new Channel();
            var T = new Thread(() =>
                {
                    PValue result;
                    try
                    {
                        result = args[0].IndirectCall(sctx, iargs.ToArray());
                    }
                    catch (Exception ex)
                    {
                        result = sctx.CreateNativePValue(ex);
                    }
                    retChan.Send(result);
                })
                {
                    IsBackground = true
                };
            T.Start();
            return PType.Object.CreatePValue(retChan);
        }
Ejemplo n.º 2
0
 public static Channel RunAsync(StackContext sctx, Func<PValue> comp)
 {
     var retChan = new Channel();
     var T = new Thread(() => retChan.Send(comp()))
         {
             IsBackground = true
         };
     T.Start();
     return retChan;
 }