Exemplo n.º 1
0
        private GraceObject mYieldFor(EvaluationContext ctx, GraceObject arg)
        {
            var n = arg.FindNativeParent <GraceNumber>();

            if (n == null)
            {
                return(GraceObject.Done);
            }
            var         sw = System.Diagnostics.Stopwatch.StartNew();
            GraceObject block;

            object[] args;
            var      ms = (int)(n.Double);

            while (sw.ElapsedMilliseconds < ms)
            {
                var delay = (int)(ms - sw.ElapsedMilliseconds);
                if (delay < 0)
                {
                    delay = 0;
                }
                if (sink.AwaitRemoteCallback(delay, out block, out args))
                {
                    processCallback(ctx, block, args);
                }
            }
            return(GraceObject.Done);
        }