分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程
HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成
HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子
| 不错i!看看!学习学习 |
|
本帖最后由 风雅。 于 2013-6-25 11:16 编辑 [code=csharp] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Thread _thread; private void btn_Start_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txt_Num.Text)) { for (int i = 0; i < int.Parse(txt_Num.Text); i++) { Application.DoEvents(); addListView(i.ToString(), Color.Red, "线程执行次数为:" + i.ToString()); } } } private void Deter(MethodInvoker method) { if (InvokeRequired) { Invoke(method); } else method(); } private void addListView(string str, Color clo, string count) { try { _thread = new Thread(new ThreadStart(() => { Deter(() => { ListViewItem list = new ListViewItem(); list.SubItems.Add("时间"); list.SubItems.Add("信息"); list.SubItems[0].Text = DateTime.Now.ToString("yyyy-HH:mm"); list.SubItems[1].Text = str; list.SubItems[2].Text = count; list.ForeColor = clo; lstView.Items.Insert(0, list); }); })); _thread.Start(); } catch (Exception) { throw; } finally { } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { _thread.Abort(); } private void panel1_Paint(object sender, PaintEventArgs e) { } } } [/code] |
|
以后会注意的!~ |
| 感谢 你的无私奉献 建议楼主如果代码量不是太大,建议贴代码,这样更方便大家阅读。 |