- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
private async void button1_Click(object sender, EventArgs e)
{
var cookie = webBrowser1.Document.Cookie;
await
Task.WhenAll(
listBox1
.Items
.Cast<string>()
.Select(async s =>
{
var data = "action=relationship&user_id=" + s + "&relation=follow";
var req = WebRequest.Create("http://example.com") as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
req.Headers["cookie"] = cookie;
using (var sw = new StreamWriter(await req.GetRequestStreamAsync(), Encoding.ASCII))
{
sw.Write(data);
sw.Close();
}
}));
listBox1.Items.Clear();
}
我已经尝试过一百万次,每次都运行两次。当它运行那两次时,它会做它应该做的事情。
它应该做的是从列表框中取出项目,并将每个项目用作 POST 请求的一部分。完成后,它会清除列表框。
谁能解释一下哪里出了问题?
最佳答案
您应该调用 req.GetResponseAsync()
来实际发送请求。
关于c# - 为什么要挂这个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18393512/
我在从 python 调用共享 c 库时遇到问题。库加载正常,公开的 3 个函数之一是可调用的,并且按预期工作;但是,当向库中添加另一个函数时,我发现其他两个不起作用。发生的事情是 python 卡在
我在使用 ImageIcon().GetImage() 时遇到问题 奇怪的是,它有时可以工作并向我显示带有 map 的窗口,而有时却不能。它也可以在其他计算机上完美运行,但不能在我的计算机上运行! 我
我们有时会遇到一个问题,即我们在 IIS 中有许多具有以下状态的请求:RequestAcquireState。 我们正在使用 SqlSessionStateStore 来管理 session 。当我们
我有一个 MobileSubstrate 插件,可以挂接跳板(不在实际的 objective-c 代码中,而是在 plist 中)。它包含一个 UIWebView,它加载一个 NSURLRequest
我正在尝试使用 Django 1.7,并按照说明进行操作 here .不幸的是,该过程似乎因以下输出而挂起: [Watt] ~/Projects/proj/proj master > python p
我正在使用 HDP 2.3.0.0-2557,我正在尝试运行如下所示的配置单元查询: beeline> !connect jdbc:hive2://localhost:10000 Connecting
我正在尝试使用 mxnet 设置 AWS Greengrass,以便在 Raspberry Pi 上进行机器学习。 当从 https://docs.aws.amazon.com/greengrass/
我是一名优秀的程序员,十分优秀!