예제 #1
0
 public void StartUpdateLeftTimeTask(bool IsPersistently = true)
 {
     Debug.WriteLine("AlphaMainPage::StartUpdateLeftTimeTask");
     if (null == UpdateLeftTimeTask || UpdateLeftTimeTaskLastStamp.AddMilliseconds(3000) < DateTime.Now)
     {
         Debug.WriteLine("AlphaMainPage::StartUpdateLeftTimeTask::kick!!!");
         UpdateLeftTimeTask = new Task
                              (
             () =>
         {
             while (null != UpdateLeftTimeTask)
             {
                 var Now = DateTime.Now;
                 UpdateLeftTimeTaskLastStamp = Now;
                 Xamarin.Forms.Device.BeginInvokeOnMainThread
                 (
                     () =>
                 {
                     ApplyCircleGraph(i => i.Now = Now);
                     var dummy = Domain.AutoUpdateLastPublicActivityAsync();
                 }
                 );
                 Task.Delay(1000 - DateTime.Now.Millisecond).Wait();
             }
         }
                              );
         UpdateLeftTimeTask.Start();
     }
     else
     if (IsPersistently)
     {
         Task.Delay(TimeSpan.FromMilliseconds(5000)).ContinueWith
         (
             (t) =>
         {
             StartUpdateLeftTimeTask(false);
         }
         );
     }
 }
예제 #2
0
        protected void UpdateLeftTime(DateTime Now, DateTime LastPublicActivity)
        {
            if (default(DateTime) != LastPublicActivity)
            {
                var Today     = Now.Date;
                var LimitTime = LastPublicActivity.AddHours(24);
                var LeftTime  = LimitTime - Now;
                LeftTimeLabel.Text      = Domain.ToString(LeftTime);
                LeftTimeLabel.TextColor = AlphaDomain.MakeLeftTimeColor(LeftTime);

                Task.Run(() => Domain.AutoUpdateLastPublicActivityAsync());
            }
            else
            {
                LeftTimeLabel.Text = "";

                /*if (Settings.IsValidUserName)
                 * {
                 *      StopUpdateLeftTimeTask();
                 * }*/
            }
            //Debug.WriteLine("AlphaDetailPage::UpdateLeftTime::LeftTime = " +LeftTimeLabel.Text);
        }