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 अनुरोध के हिस्से के रूप में उपयोग करना है। फिर जब यह हो जाता है, तो यह सूची बॉक्स को साफ़ करता है।
कोई बता सकता है कि क्या गलत है?
आपको URL-encode 's' की आवश्यकता है। – SLaks
एस बस एक संख्या है। तो यूआरएल एन्कोडिंग की कोई ज़रूरत नहीं है, लेकिन धन्यवाद। –
समस्या वास्तव में क्या है? – SLaks