当前位置: 首页 > news >正文

网站规划与建设网站如何让百度抓取

网站规划与建设,网站如何让百度抓取,建设网站的风险管理,建筑专业名词网站文章目录实例一#xff1a;【方便理解#xff0c;常用#xff01;】源码#xff1a;运行效果#xff1a;实例二#xff1a;【重在理解代码本身】源码#xff1a;运行效果#xff1a;参考#xff1a;实例一#xff1a;【方便理解#xff0c;常用#xff01;】 跨线… 文章目录实例一【方便理解常用】源码运行效果实例二【重在理解代码本身】源码运行效果参考实例一【方便理解常用】 跨线程更新进度条【事件触发(进度条值增加的方法在另一个命名空间下的类中)】 源码 AddNum.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ProgressBarAddNum {public class AddNum{public static int Num 0;public delegate void UpdateProgress(int index);public static event UpdateProgress onUpdateProgress;public static void Add(){UpdateProgressMethod(Num 100 ? 0 : Num);Num2; }public static void UpdateProgressMethod(int i){if (onUpdateProgress ! null){onUpdateProgress.BeginInvoke(i, null, null);}}} }Form1.cs using ProgressBarAddNum; using System; using System.Threading; using System.Windows.Forms;namespace WindowsFormsApp1 {public partial class Form1 : Form{public Form1(){InitializeComponent();AddNum.onUpdateProgress AddNum_onUpdateProgress;//注意:此事件绑定只绑定一次不能多次绑定}public static Thread thread;private void button1_Click(object sender, EventArgs e){AddNum.Num 0;thread new Thread(Process);thread.IsBackground true;thread.Start();}public delegate void UpdateProgress(int index);private void AddNum_onUpdateProgress(int index){if (progressBar1.InvokeRequired){UpdateProgress dus new UpdateProgress(AddNum_onUpdateProgress);this.BeginInvoke(dus, new object[] { index });//方法一//this.BeginInvoke(dus, index);//方法二//progressBar1.Invoke(dus, new object[] { index });//方法三也可以同时更新textBox1的值【】//progressBar1.Invoke(dus, index);//方法四也可以同时更新textBox1的值【】}else{progressBar1.Value index;textBox1.Text index.ToString();//注意同时更新textBox1的值}}private void Process(){while (true){if (AddNum.Num 100){AddNum.Add();Thread.Sleep(50);}else{break;}}}private void button2_Click(object sender, EventArgs e){if (thread ! null){thread.Abort();thread null;}progressBar1.Value 0;textBox1.Text 0;}} } 运行效果 实例二【重在理解代码本身】 C#中的事件是建立在委托的基础上标准的事件模型应该包括以下几点 声明一个用于定义事件的委托这里用系统自带的泛型委托原型EventHandler如public delegate void EventHandler(object sender,TEventArgs e);这里面的TEventArgs是由我们自定义的参数类型继承自EventArgs基类事件参数的名称以EventArgs结束声明事件的委托原型即EventHandler它的返回值为void声明事件的委托原型即EventHandler它有两个参数sender和esender表示事件触发者e表示事件触发时的参数事件的声明是在普通委托声明的前面加上event关键字如public event EventHandler FileUploaded; 源码 文件下载时要实时更新进度条这时更新进度的方法就应该由下载类在下载的同时根据实时的下载进度利用事件去同步更新进度条的值。代码如下 using System; using System.Threading; using System.Windows.Forms;namespace WindowsFormsApp2 {public partial class Form1 : Form{public Form1(){InitializeComponent();}private void ShowProcess(object sender, FileUploaderEventArgs e){//定义委托Action t () {progressBar1.Value e.FileProgress;label1.Text e.FileProgress.ToString();};//跨线程操作this.BeginInvoke(t);Thread.Sleep(100);//【注意】:触发事件后的方法要执行完毕才会退出while中的触发事件代码}private void button1_Click_1(object sender, EventArgs e){FileUploader f1 new FileUploader();f1.FileUploaded ShowProcess; //绑定事件ThreadPool.QueueUserWorkItem((a) f1.Upload());//加入线程池}}/// summary/// 文件下载类/// /summaryclass FileUploader{public event EventHandlerFileUploaderEventArgs FileUploaded;//定义事件public void Upload(){var e new FileUploaderEventArgs() { FileProgress 0 };while (e.FileProgress 100){//DoSomething();//执行一些下载任务e.FileProgress;FileUploaded(this, e);//触发事件//Thread.Sleep(100);//【注意】或者注释掉上边的代码使用这个实际中更常用}}}/// summary/// 自定义参数/// /summaryclass FileUploaderEventArgs : EventArgs{public int FileProgress { get; set; }} }运行效果 参考 https://www.cnblogs.com/maitian-lf/p/3654146.html
http://www.hkea.cn/news/14310612/

相关文章:

  • 深圳有多少网站建设公司wordpress文件调用函数
  • 海南手机网站建设网络营销推广的实施计划
  • 王晴儿网站建设方案关于做网站策划书
  • 企业网站 空间网上国网app缴费
  • 建设好网站能赚到钱吗百度云盘资源
  • 番禺网站建设公司有哪些专业微信网站建设价格
  • 手机微网站与微官网贵州省铁路建设办公室网站
  • 项目商业网站建设方案深圳中装建设集团有限公司
  • 门户型网站模板美丽深圳微信公众号二维码
  • 资源网站的建设汾阳今天重大新闻
  • 西安网站搭建建设定制网站开发要学哪些知识
  • ASP.NET与网站开发编程实战开发一款小程序需要多少钱
  • 个人网站模板怎么做河间网站建设制作
  • 深圳网站制作公司价位网站百度指数分析
  • 网站建设信息推荐网站做了301怎么查看跳转前网站
  • 泰然建设网站wordpress站内计费搜索
  • 电子商业网站建设步骤网站搭建与网站建设
  • 学做简单网站视频教程建筑网站建设案例
  • 做网站商城赔了8万如何成立一家咨询公司
  • 要制作一个自己的网站制作一个自适应网站源码
  • 网站建设方案书的内容广州广州网站建设公司
  • 常用素材网站跨境电商一站式服务平台
  • 乌海建设局网站兴趣电商平台有哪些
  • 文章 百度网站创建及发展历史网站管理是什么
  • 品牌网站建设代理深圳生活免费信息网
  • 水果网站开发所需的成本湖南专业做网站公司
  • 门户网站模板源码下载徐州手机网站建设公司哪家好
  • 深圳网站建设 卓越迈网站开发询价单
  • WordPress生成网站地图软件商城免费下载安装包
  • 十堰建设局网站深圳网站建设哪些