最新下载
热门教程
- 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];
相关文章
- 《原神》5.2卡池抽取建议 11-14
- 《原神》5.2版本新怪物介绍 11-14
- 《原神》希诺宁增伤触发方法 11-14
- 《原神》循音觅奇活动入口 11-14
- 《原神》循音觅奇兑换码获取方法 11-14
- 《原神》花羽会活动飞行技巧介绍 11-14