Ejemplo n.º 1
0
        public Timer(Dispatcher disp, EventHandler handler, int delay, int interval, object state)
        {
            _dispatcher = disp;
            _handler = handler;
            _state = state;

            _timer = new System.Threading.Timer((o) =>
            {
                var timer = o as Timer;
                timer._dispatcher.BeginInvoke((Action)(() =>
                {
                    try
                    {
                        timer._handler(null, new CallbackEventArgs(timer._state));
                    }
                    catch (SystemException ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.ToString());
                    }
                }));
            }, this, delay, interval);
        }
Ejemplo n.º 2
0
 public Timer(Dispatcher disp, EventHandler handler, int delay, object state)
     : this(disp, handler, delay, System.Threading.Timeout.Infinite, state)
 {
 }
 public DispatcherSynchronizationContext(Dispatcher dispatcher)
 {
     _dispatcher = dispatcher;
 }