zoukankan      html  css  js  c++  java
  • c# update check

    public  class UpdateChecker {
    
            public static  event EventHandler completeCheck;
            private static  bool isChecking = false;
            private static WebClient wc;
            public static  void doUpdateCheck() {
    
                if (isChecking) return;
                isChecking = true ;
                 wc = new WebClient();
                 wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
                 wc.DownloadStringAsync(new Uri("https://files.cnblogs.com/files/wgscd/appupdate.xml"));
            }
    
            private   static void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
            {
                try
                {
                    // MessageBox.Show(""+e.Result ,"update",MessageBoxButton.YesNo);
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml("" + e.Result);
                    string localVar="3.8";//test
                    string serverVer = doc.SelectSingleNode("app").Attributes["version"].Value;
                    string serverDate = doc.SelectSingleNode("app").Attributes["update_date"].Value;
                    string tip = doc.SelectSingleNode("app/tip").InnerText;
                    if (localVar.CompareTo (serverVer)<0) {
                        MessageBox.Show("the new version: " + serverVer + "
     " + tip + " 
     update?
    ", "update", MessageBoxButton.YesNo);
                    }
                    if (completeCheck != null) { completeCheck(sender, e); }
                    isChecking = false;
                }
                catch { }
                wc.DownloadStringCompleted -= new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
                
            }
    
        
        
        
        }
    

      

  • 相关阅读:
    第八周上机作业
    第七周课后作业
    第七周上机作业
    第六周课后作业
    第六周上机
    第九周JAVA
    第八周JAVA
    第8次JAVA作业
    第七周JAVA
    第7周JAVA
  • 原文地址:https://www.cnblogs.com/wgscd/p/9334431.html
Copyright © 2011-2022 走看看