Пример #1
0
 public void Update()
 {
     if (!Paused)
     {
         Actions.Invoke();
     }
 }
Пример #2
0
        public static long TimeMillis(Runnable r)
        {
            long timeA = DateTime.Now.Ticks;

            r.Invoke();
            long timeB = DateTime.Now.Ticks;

            return((timeB - timeA) / 10000);
        }
Пример #3
0
        public static long TimeNano(Runnable r)
        {
            long timeA = DateTime.Now.Ticks;

            r.Invoke();
            long timeB = DateTime.Now.Ticks;

            return(100 * (timeB - timeA));
        }
Пример #4
0
        public static long TimeMillis(Runnable r)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            r.Invoke();
            stopWatch.Stop();
            return(stopWatch.ElapsedMilliseconds);
        }
Пример #5
0
        public static long TimeMicro(Runnable r)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            r.Invoke();
            stopWatch.Stop();
            return(100 * stopWatch.ElapsedTicks);
        }
Пример #6
0
        public static long TimeMillis(Runnable r)
        {
            long timeA;
            long timeB;

            QueryPerformanceCounter(out timeA);
            r.Invoke();
            QueryPerformanceCounter(out timeB);
            return((long)((timeB - timeA) * MpMilli));
        }
Пример #7
0
 public virtual void setPending(int code, String message)
 {
     xmitAbortCode    = code;
     xmitAbortMessage = message;
     xmitAbortPending = XmitState.PENDING;
     if (xmitRequestListener != null)
     {
         xmitRequestListener.Invoke();
     }
 }
 private static void TryInvalid(Runnable r)
 {
     try {
         r.Invoke();
         Assert.Fail();
     }
     catch (EPSubscriberException ex) {
         AssertMessage(
             ex,
             "Setting a subscriber is not allowed for the statement, the statement has been compiled with allowSubscriber=false");
     }
 }
    private IEnumerator PlayInTransition(TransitionFunction <float> transition, float time,
                                         Action <float> changeTransparency, Runnable endFunction = null)
    {
        for (float value = 0; value <= time; value += Time.fixedDeltaTime)
        {
            var newTransparency = transition(value, 0, 1, logoFadeInTime);
            changeTransparency?.Invoke(newTransparency);
            yield return(new WaitForFixedUpdate());
        }

        changeTransparency?.Invoke(1f);

        endFunction?.Invoke();
    }
Пример #10
0
        public static bool TimeoutLock(object obj, Runnable runnable, int millisecondsTimeOut)
        {
            bool isLockTaken = Monitor.TryEnter(obj, millisecondsTimeOut);

            if (isLockTaken)
            {
                try
                {
                    runnable?.Invoke();
                }
                finally {
                    Monitor.Exit(obj);
                }
            }
            return(isLockTaken);
        }
Пример #11
0
        public Thread NewThread(Runnable runnable)
        {
            var name = "com.espertech.esper." + _prefix + "-" + _runtimeURI + "-" + _currThreadCount;
            _currThreadCount++;

            var thread = new Thread(() => runnable.Invoke());
            thread.Name = name;
            thread.IsBackground = true;
            thread.Priority = _threadPriority;

            if (Log.IsDebugEnabled) {
                Log.Debug("Creating thread '" + name + "' : " + thread + " priority " + _threadPriority);
            }

            return thread;
        }
Пример #12
0
        private static void RunAssertionDisambiguate(
            RegressionEnvironment env,
            string firstEpl,
            string secondEpl,
            string useEpl,
            Runnable assertion)
        {
            var first = env.Compile("module a;\n @public " + firstEpl + "\n");
            var second = env.Compile("module b;\n @public " + secondEpl + "\n");
            env.Deploy(first);
            env.Deploy(second);

            var path = new RegressionPath();
            path.Add(first);
            path.Add(second);
            env.CompileDeploy("uses b;\n @name('s0') " + useEpl + "\n", path).AddListener("s0");

            assertion.Invoke();

            env.UndeployAll();
        }
        public void Popup(string message, long timeout, ConsoleColor borderColor = ConsoleColor.Blue, Runnable onExpire = null)
        {
            TextView popup = new TextView(
                new ViewData("ConsoleForms.TextBox")
                .SetAttribute("padding_left", 2)
                .SetAttribute("padding_right", 2)
                .SetAttribute("padding_top", 1)
                .SetAttribute("padding_bottom", 1)
                .AddNested(new ViewData("Text", message)), // Add message
                LangManager.NO_LANG
                )
            {
                BackgroundColor = ConsoleColor.White,
                TextColor       = ConsoleColor.Black,
                BorderColor     = borderColor,
            };

            AddView(popup, LayoutMeta.Centering(popup));

            new Timer(() => {
                CloseView(popup);
                onExpire?.Invoke();
            }, timeout).Start();
        }
Пример #14
0
 private static void TryAssertDestroyed(Runnable r)
 {
     Assert.That(() => r.Invoke(), Throws.Exception.InstanceOf<EPRuntimeDestroyedException>());
 }
Пример #15
0
    private static IEnumerator DelayedExecution(Runnable function, float delay)
    {
        yield return(new WaitForSeconds(delay));

        function?.Invoke();
    }