Beispiel #1
0
 public void clearInterval(UITimer timer)
 {
     if (timer != null)
     {
         timer.Stop();
     }
 }
Beispiel #2
0
        /// <summary>Called before the game/scene is unloaded to remove any timers.</summary>
        public static void OnUnload(Document document)
        {
            if (FirstActive != null)
            {
                int     count   = 0;
                UITimer current = FirstActive;
                FirstActive = null;

                while (current != null)
                {
                    if (document == null || current.Document == document)
                    {
                        count++;
                        current.Stop();
                    }

                    current = current.Next;
                }

                if (count != 0)
                {
                    Dom.Log.Add("Cleared " + count + " leaked interval timers. This message is harmless but can help discover if you have accidentally left setInterval running (note: marquee uses these timers too).");
                }
            }
        }
        /// <summary>Clears all code.</summary>
        public void ClearCode()
        {
            Engines         = null;
            FinishedParsing = false;

            // Clear any running intervals:
            UITimer.OnUnload(this);
        }
Beispiel #4
0
        internal override void RemovedFromDOM()
        {
            base.RemovedFromDOM();

            // Clear the timer:
            if (Timer != null)
            {
                Timer.Stop();
                Timer = null;
            }
        }
        public void OnApplicationQuit()
        {
            // Run OnBeforeUnload, if an event is still attached:
            if (UI.document != null)
            {
                // Run onbeforeunload (always trusted):
                UI.document.window.dispatchEvent(new BeforeUnloadEvent());
            }

            // Make sure all timers are halted:
            UITimer.OnUnload(null);
        }
Beispiel #6
0
        /// <summary>Call this to begin a marquee.</summary>
        public void Start()
        {
            if (Active)
            {
                return;
            }

            Active = true;

            // Start our timer:
            Timer = new UITimer(false, ScrollDelay, OnTick);

            Element.Run("onstart");
        }
Beispiel #7
0
        /// <summary>Call this to stop a scrolling marquee.</summary>
        public void Stop()
        {
            if (!Active)
            {
                return;
            }

            Active = false;

            // Stop and clear the timer:
            Timer.Stop();

            Timer = null;

            Element.Run("onstop");
        }
Beispiel #8
0
        /// <summary>No timers available on Windows 8 so it's got to use the Unity update thread instead.</summary>
        public void Update()
        {
            UITimer current = FirstActive;

            while (current != null)
            {
                current.CurrentTime += Time.deltaTime;

                if (current.CurrentTime > current.MaxTime)
                {
                    // Tick!
                    current.CurrentTime = 0f;
                    current.Elapsed(null);
                }

                current = current.Next;
            }
        }
Beispiel #9
0
        /// <summary>Stops this timer from running anymore.</summary>
        public void Stop()
        {
                        #if UNITY_WP8
            if (InternalTimer == null)
            {
                return;
            }

            InternalTimer.Dispose();
            InternalTimer = null;
                        #elif UNITY_METRO
                        #else
            if (InternalTimer == null)
            {
                return;
            }

            InternalTimer.Enabled = false;
            InternalTimer         = null;
                        #endif

            if (!OneOff)
            {
                // Remove from active queue:
                if (Next == null)
                {
                    LastActive = Previous;
                }
                else
                {
                    Next.Previous = Previous;
                }

                if (Previous == null)
                {
                    FirstActive = Next;
                }
                else
                {
                    Previous.Next = Next;
                }
            }
        }
Beispiel #10
0
        /// <summary>Call this to begin a marquee.</summary>
        public void Start()
        {
            if (Active)
            {
                return;
            }

            Active = true;

            // Doesn't bubble:
            Dom.Event e = new Dom.Event("start");
            e.SetTrusted(false);

            if (dispatchEvent(e))
            {
                // Start our timer:
                Timer          = new UITimer(false, ScrollDelay, OnTick);
                Timer.Document = document_;
            }
        }
Beispiel #11
0
        /// <summary>Call this to stop a scrolling marquee.</summary>
        public void Stop()
        {
            if (!Active)
            {
                return;
            }

            // Doesn't bubble:
            Dom.Event e = new Dom.Event("stop");
            e.SetTrusted(false);

            if (dispatchEvent(e))
            {
                Active = false;

                // Stop and clear the timer:
                Timer.Stop();

                Timer = null;
            }
        }
Beispiel #12
0
        private void Setup(bool oneOff, int interval)
        {
            if (interval <= 0)
            {
                throw new Exception("Invalid timing interval or callback.");
            }

            Interval = interval;

            if (Callback == null && OnComplete == null)
            {
                throw new Exception("A callback must be provided for timer methods.");
            }

            OneOff = oneOff;
                        #if UNITY_WP8
            InternalTimer = new System.Threading.Timer(Elapsed, null, 0, interval);
                        #elif UNITY_METRO
            MaxTime = (float)Interval / 1000f;
                        #else
            InternalTimer          = new System.Timers.Timer();
            InternalTimer.Elapsed += Elapsed;
            InternalTimer.Interval = interval;
            InternalTimer.Start();
                        #endif

            if (!OneOff)
            {
                // Add to active set:
                if (FirstActive == null)
                {
                    FirstActive = LastActive = this;
                }
                else
                {
                    Previous   = LastActive;
                    LastActive = LastActive.Next = this;
                }
            }
        }