A simple helper class that gives a way to run things on the UI thread. The app must call Initialize once during app start, using inside OnLaunch.
Ejemplo n.º 1
0
 public static void Initialize()
 {
     instance = new UiDispatcher()
     {
         dispatcher = Dispatcher.CurrentDispatcher
     };
 }
Ejemplo n.º 2
0
 public static void Initialize()
 {
     instance = new UiDispatcher()
     {
         dispatcher = Dispatcher.CurrentDispatcher
     };
 }
Ejemplo n.º 3
0
 private void OnPropertyChanged(string name)
 {
     if (PropertyChanged != null)
     {
         UiDispatcher.RunOnUIThread(() =>
         {
             PropertyChanged(this, new PropertyChangedEventArgs(name));
         });
     }
 }
Ejemplo n.º 4
0
 void StartProgressTimer()
 {
     if (progressTimer == null)
     {
         UiDispatcher.RunOnUIThread(() =>
         {
             progressTimer          = new DispatcherTimer();
             progressTimer.Tick    += OnProgressTick;
             progressTimer.Interval = TimeSpan.FromMilliseconds(30);
             progressTimer.Start();
         });
     }
 }
Ejemplo n.º 5
0
        void StopProgressTimer()
        {
            DispatcherTimer temp = progressTimer;

            progressTimer = null;

            if (temp != null)
            {
                UiDispatcher.RunOnUIThread(() =>
                {
                    temp.Stop();
                    temp.Tick -= OnProgressTick;
                });
            }
        }
Ejemplo n.º 6
0
            private void OnDelayTimerTick(object state)
            {
                int endTime = Environment.TickCount;
                int diff    = startTime - endTime;

                Action a = this.delayedAction;

                StopDelayTimer();

                if (a != null)
                {
                    UiDispatcher.RunOnUIThread(() =>
                    {
                        try
                        {
                            a();
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("OnDelayTimerTick caught unhandled exception: " + ex.ToString());
                        }
                    });
                }
            }