Пример #1
0
 /// <summary>
 /// Execute the update event
 /// </summary>
 public void Update()
 {
     // Do timing
     if (UpdateTimer.IsRunning)
     {
         LastUpdateDuration     = UpdateTimer.Elapsed.TotalSeconds;
         SmoothedUpdateDuration = (SmoothedUpdateDuration * 9.0 + LastUpdateDuration) / 10.0;
         UpdateTimer.Restart();
     }
     else
     {
         UpdateTimer.Start();
     }
     // Call update event
     OnUpdate();
     // Add to LastUpdate
     LastUpdate += 1.0 / UpdateRate;
 }
Пример #2
0
 private static void CheckForUpdate()
 {
     UpdateTimer.Restart();
     Client.GetAsync(uri).AsTask().ContinueWith((Task <HttpResponseMessage> response) =>
     {
         IHttpContent responseContent = response.Result.Content;
         foreach (string str in Regex.Split(responseContent.ToString(), ","))
         {
             if (str.Contains("\"tag_name\":"))
             {
                 UpdateVersion = str.Replace("\"tag_name\":\"", "").Replace("\"", "");
                 if (ScreamAtUser && !UpdateAvailibleFlag)
                 {
                     if (str.Replace("\"tag_name\":\"", "").Replace("\"", "") != Version)
                     {
                         SendNotification("Update Available",
                                          UpdateVersion + " is published on github. Go there for the latest version");
                     }
                 }
                 UpdateAvailibleFlag = UpdateVersion != Version;
             }
         }
     });
 }