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

网页抓取 wordpress百度优化公司

网页抓取 wordpress,百度优化公司,如何帮助网站吸引流量,自己做的影视网站买会员违法吗上位机开发中一定会用到的技术就是 设备的线程开始运行执行生产流程,在生产过程中会有要打开安全门或暂停设备动作,人为去排除设备小问题的时就要用到暂停功能,问题排除后设备继续运行,生产完成后设备停止。 这些操作是上位机开发…

        上位机开发中一定会用到的技术就是 设备的线程开始运行执行生产流程,在生产过程中会有要打开安全门或暂停设备动作,人为去排除设备小问题的时就要用到暂停功能,问题排除后设备继续运行,生产完成后设备停止。 这些操作是上位机开发中必须要实现的功能。下面是一个简单的示例。

 1.界面

2.代码

2.1主要用到的对象

//线程源
private CancellationTokenSource cts = new CancellationTokenSource();
//手动停止事件对象
private ManualResetEvent resetEvent = new ManualResetEvent(true);
//线程
private Task task;

2.2 开始

/// <summary>
/// 开 始
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnStart_Click(object sender, EventArgs e)
{if (cts.IsCancellationRequested){cts = new CancellationTokenSource();}resetEvent.Set();task = Task.Factory.StartNew(() =>{int count = 1;Color clrInfo = Color.Blue;while (!cts.IsCancellationRequested){resetEvent.WaitOne();//阻止当前线程var strInfo = "运行日志[" + count + "]";AddListViewThread(null, strInfo, clrInfo);count++;Thread.Sleep(1000);}});
}

2.3 暂 停

/// <summary>
/// 暂 停
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnPause_Click(object sender, EventArgs e)
{resetEvent.Reset();
}

2.4继 续

/// <summary>
/// 继 续
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnContinue_Click(object sender, EventArgs e)
{resetEvent.Set();
}

2.5停 止

/// <summary>
/// 停 止
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnStop_Click(object sender, EventArgs e)
{cts.Cancel();
}

全部代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;namespace TaskWindowsFormsApp
{public partial class Form1 : Form{public Form1(){InitializeComponent();}delegate void AddListViewCallback(string strTime, string strContent, Color textColor);//线程源private CancellationTokenSource cts = new CancellationTokenSource();//手动停止事件对象private ManualResetEvent resetEvent = new ManualResetEvent(true);//线程private Task task;/// <summary>/// 开 始/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnStart_Click(object sender, EventArgs e){if (cts.IsCancellationRequested){cts = new CancellationTokenSource();}resetEvent.Set();task = Task.Factory.StartNew(() =>{int count = 1;Color clrInfo = Color.Blue;while (!cts.IsCancellationRequested){resetEvent.WaitOne();//阻止当前线程var strInfo = "运行日志[" + count + "]";AddListViewThread(null, strInfo, clrInfo);count++;Thread.Sleep(1000);}});}/// <summary>/// 暂 停/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnPause_Click(object sender, EventArgs e){resetEvent.Reset();}/// <summary>/// 继 续/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnContinue_Click(object sender, EventArgs e){resetEvent.Set();}/// <summary>/// 显示(添加)日志/// </summary>/// <param name="strTime">时间</param>/// <param name="strContent">内裤</param>/// <param name="textColor">颜色</param>public void AddListViewThread(string strTime, string strContent, Color textColor){if (this.IsDisposed){return;}if (this.listViewWorkLogs.InvokeRequired){//获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用 Invoke 方法,因为调用方位于创建控件所在的线程以外的线程中AddListViewCallback d = new AddListViewCallback(AddListViewThread);this.Invoke(d, new object[] { strTime, strContent, textColor });}else{AddContent2ListView(strTime, strContent, textColor);}}/// <summary>/// 显示(添加)日志/// </summary>/// <param name="strTime">时间</param>/// <param name="strContent">内裤</param>/// <param name="textColor">颜色</param>public void AddContent2ListView(string strTime, string strContent, Color textColor){try{if (strTime == null){strTime = string.Format("{0}:{1}:{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);}int nCount = listViewWorkLogs.Items.Count;if (nCount > 600){for (int i = nCount - 1; i > 100; i--){listViewWorkLogs.Items.RemoveAt(i);}}}catch{int nCount = listViewWorkLogs.Items.Count;if (nCount > 600){listViewWorkLogs.Clear();}}ListViewItem lvItem = new ListViewItem();lvItem.ForeColor = textColor;lvItem.Text = strTime;lvItem.StateImageIndex = 0;lvItem.SubItems.Add(strContent);this.listViewWorkLogs.Items.Insert(0, lvItem);}/// <summary>/// 停 止/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnStop_Click(object sender, EventArgs e){cts.Cancel();}}
}

http://www.yidumall.com/news/36400.html

相关文章:

  • 潍坊网站建设8年昆山网站制作哪家好
  • 网站的维护与更新吗百度直播间
  • Wordpress独立站收款商品关键词举例
  • 想开一个做网站的公司怎么进行网站关键词优化
  • 宣传网站怎么做的成都私人网站建设
  • 珠海网站设计佛山网站建设模板
  • 免费网站建设网站有那些怎么建企业网站
  • 做网站需多少钱百度入口网页版
  • 如何选择网站定制公司中国关键词
  • 江苏网站建设官网sem网站推广怎么做
  • 织梦模板大气网站建设类网站模板下载b2b平台有哪些
  • 学ui wordpress模板上海seo优化公司 kinglink
  • 怎么用百度云做网站空间龙岗网站建设
  • 网站的建设目标有哪些什么是seo搜索
  • 网站备案没通过不了公司网络优化方案
  • 做网站的开题报告微信广告投放收费标准
  • 拟采用建站技术seo整站优化解决方案
  • 做 ps pr 赚钱的 网站网站免费建站app
  • 万网注册域名做简单网站网站可以自己做吗
  • 具有品牌的广州做网站广告投放优化师
  • 政府电子网站建设解决方案百度广告位
  • 自建门户网站网站快速排名上
  • 河源市规划建设局网站友情链接教程
  • 大良营销网站建设行情怎么上百度搜索
  • 万网有跟企业做网站吗微博营销软件
  • 郑州网站开发定制成都seo排名
  • 网站建设开发报价单微信群拉人的营销方法
  • 网站内部链接是怎么做的专业seo培训
  • 做淘宝的货源网站seo案例模板
  • 百度做商务网站多少钱排位及资讯