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);
                
            }
    
        
        
        
        }
    

      

  • 相关阅读:
    魔法方法中的__str__和__repr__区别
    新建分类目录后,点击显示错误页面?
    3.用while和for循环分别计算100以内奇数和偶数的和,并输出。
    2.for循环实现打印1到10
    1.while循环实现打印1到10
    021_for语句
    014_运算符_字符串连接
    020_while语句
    019_增强switch语句
    018_switch语句
  • 原文地址:https://www.cnblogs.com/wgscd/p/9334431.html
Copyright © 2011-2022 走看看