예제 #1
0
        /// <summary>
        /// 检测书源可用率
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Testing_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("状态码如果为1代表书源站正常访问,如果为0代表不可访问", "提示");
            Thread thread = new Thread(new ThreadStart(delegate
            {
                //遍历源站
                foreach (BookSource bookSource in DataFetch.GetBookSources())
                {
                    //1代表网站可以访问,0代表不可以访问
                    int state = GetHtml.GetUnicom(bookSource.Url) ? 1 : 0;
                    DataFetch.UpdateState((int)bookSource.Id, state);
                }

                this.Dispatcher.Invoke(new Action(() =>
                {
                    //加载书源
                    ListSource.ItemsSource = DataFetch.GetBookSources();
                }));
            }));

            thread.IsBackground = true;
            thread.Start();
        }