日期:2014-05-17 浏览次数:21051 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Net;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private static string str_url = string.Empty;
public delegate void SetTextHandler(string text);
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (toolStripTextBox1.Text.Length > 0)
{
str_url = toolStripTextBox1.Text.Trim();
ParameterizedThreadStart ParStart = new ParameterizedThreadStart(GetPageSource);
Thread myThread = new Thread(ParStart);
//是否背景线程根据自己需要加,加上后理论上不影响界面的操作,就是不卡
myThread.IsBackground = true;
object o = str_url;
myThread.Start(o);
//GetPageSource(toolStripTextBox1.Text.ToString().Trim());
}
}
private void GetPageSource(object url)
{
Uri uri = new Uri(url.ToString());
HttpWebRequest hwReq = (HttpW