Esempio n. 1
0
        private void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            try
            {
                using (MemoryStream ms = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(e.Result)))
                {
                    updInfo        = jsonSerializer.ReadObject(ms) as UpdateInfo;
                    updInfo.Loaded = true;
                }

                if (IsNewerVersionAvailable())
                {
                    OnUpdateAvailable?.Invoke();
                }
            }
            catch (Exception ex)
            {
                OnExceptionRaised?.Invoke(ex);
            }
        }
Esempio n. 2
0
 private void WC_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     try
     {
         int fileIndex = (int)sender;
         File.WriteAllBytes(updateDir + updInfo.FilePath[fileIndex], e.Result);
         OnFileDownloaded?.Invoke(updInfo.FilePath[fileIndex]);
         lock (thislock)
         {
             wipCount--;
             if (wipCount == 0)
             {
                 OnUpdateDone?.Invoke();
             }
         }
     }
     catch (Exception ex)
     {
         OnExceptionRaised?.Invoke(ex);
     }
 }