最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C# 刚写的 HttpRequsetResponse 类,异步、事件... 还热乎着呢!
时间:2022-07-02 12:04:16 编辑:袖梨 来源:一聚教程网
//调用示例:
private void button1_Click(object sender, System.EventArgs e)
{
HttpRequestResponse xx = new HttpRequestResponse();
xx.DataArrival += new DataArrivalEventHandler(xx_DataArrival);
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","Post");
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","get");
}
private void xx_DataArrival(object sender, DataArrivalEventArgs e)
{
Console.WriteLine(e.RecievedData);
Console.WriteLine(e.IsComplete);
}
//========================
//Class1.cs
using System;
using System.Net;
using System.Threading;
using System.Text;
using System.IO;
public class RequestState
{
const int BUFFER_SIZE = 1024;
public System.Text.StringBuilder RequestData;
public byte[] BufferRead;
public System.Net.HttpWebRequest Request;
public System.IO.Stream ResponseStream;
public System.Text.Decoder StreamDecode = System.Text.Encoding.GetEncoding("gb2312").GetDecoder();
public RequestState()
{
BufferRead = new byte[BUFFER_SIZE];
private void button1_Click(object sender, System.EventArgs e)
{
HttpRequestResponse xx = new HttpRequestResponse();
xx.DataArrival += new DataArrivalEventHandler(xx_DataArrival);
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","Post");
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","get");
}
private void xx_DataArrival(object sender, DataArrivalEventArgs e)
{
Console.WriteLine(e.RecievedData);
Console.WriteLine(e.IsComplete);
}
//========================
//Class1.cs
using System;
using System.Net;
using System.Threading;
using System.Text;
using System.IO;
public class RequestState
{
const int BUFFER_SIZE = 1024;
public System.Text.StringBuilder RequestData;
public byte[] BufferRead;
public System.Net.HttpWebRequest Request;
public System.IO.Stream ResponseStream;
public System.Text.Decoder StreamDecode = System.Text.Encoding.GetEncoding("gb2312").GetDecoder();
public RequestState()
{
BufferRead = new byte[BUFFER_SIZE];
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20