Thursday, 15 April 2010

c# - Windows process is unable to terminate when an application performs lots of async http requests -



c# - Windows process is unable to terminate when an application performs lots of async http requests -

i have question regarding unusual behavior of process performs lots of async unsuccessful requests server. unusual thing it's impossible exit/stop/kill process. if compile , run programme on windows 8 machine process hangs , haven't found solution how kill it. reboot helps.

could explain mentioned behavior please.

thanks.

ps: when utilize taskmanager kill process

internal class programme { private const int totalrequests = 2000; private static void main(string[] args) { var cancellationtockensource = new cancellationtokensource(); loadtest(cancellationtockensource); console.writeline("press key break"); console.readline(); cancellationtockensource.cancel(); } private static async task loadtest(cancellationtokensource cancellationtockensource) { stopwatch stopwatch = stopwatch.startnew(); var requests = new list<task>(totalrequests); (int = 0; < totalrequests; ++i) { requests.add(request(cancellationtockensource.token)); } seek { await task.whenall(requests); } grab (exception e) { console.writeline(e); } stopwatch.stop(); console.writeline("{0} req/sec", stopwatch.elapsed.totalseconds/totalrequests); } private static httprequestmessage createmessage() { var url = new uri("http://ya.ru:8080/234234234234x"); var message = new httprequestmessage(httpmethod.get, url); message.headers.accept.add(mediatypewithqualityheadervalue.parse("application/json")); homecoming message; } protected static async task<string> request(cancellationtoken token) { using (var client = new httpclient()) { httpresponsemessage response = await client.sendasync(createmessage(), token); string content = await response.content.readasstringasync(); homecoming content; } } }

c# task-parallel-library async-await web-api

No comments:

Post a Comment