Ejemplo n.º 1
0
        /// <summary>
        /// Функция таймера для проверки подключения
        /// </summary>
        /// <param name="parameter"></param>
        private static async void OnTimer(object parameter)
        {
            var result = new AuthorizationResult();

            try
            {
                result = await TimerClient.Authorization();
            }
            catch (Exception exc)
            {
                await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Ошибка подключения", exc.Message, "Ок");

                Xamarin.Forms.Application.Current.MainPage = new Xamarin.Forms.NavigationPage(new Views.AuthoPage());
                return;
            }

            switch (result)
            {
            case AuthorizationResult.Ok:

                break;

            case AuthorizationResult.Error:
                await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Ошибка подключения", "Нет подключения к серверу", "Ок");

                Xamarin.Forms.Application.Current.MainPage = new Xamarin.Forms.NavigationPage(new Views.AuthoPage());
                break;
            }
        }
Ejemplo n.º 2
0
        public void start_notifying(TimerClient client_to_be_notified, TimeSpan span)
        {
            stop_notifying(client_to_be_notified);

            var timer = factory.create_for(span);
            timer.Elapsed += (o, e) =>
            {
                client_to_be_notified.notify();
            };
            timer.Start();
            timers[client_to_be_notified] = timer;
        }
Ejemplo n.º 3
0
 public void Register(int timeOut, TimerClient client)
 {
     this.client = client;
     this.timer  = new Timer(this.OnTimedEvent, null, timeOut, Timeout.Infinite);
 }
Ejemplo n.º 4
0
 public void Register(int timeout, int timeOutId, TimerClient client)
 {
 }
Ejemplo n.º 5
0
 public void stop_notifying(TimerClient client_to_stop_notifying)
 {
     if (!timers.ContainsKey(client_to_stop_notifying)) return;
     timers[client_to_stop_notifying].Stop();
     timers[client_to_stop_notifying].Dispose();
 }