vb.net - .Net 4.5 Await Breakpoints -


i couldn't find full example postasync had piece 1 together. therefore, not sure if viewing limitation debugger or did wrong.

this trying do:

i have go through list , make web service call each item on list. thought use new 4.5 async stuff keep flowing without blocking during each call web service.

i've done tone of research , watched jon skeet's video on tekpub, i'm still not sure if doing correctly. is, when set break points async method never returns control caller. seems go along synchronous version.

question:

is normal debugger appear synchronous or indicate code not implemented correctly?

here post method:

public async function postsecurexmlasync(byval username string, byval password string, byval xmltosend string) task(of string)      dim content = new stringcontent(xmltosend, encoding.utf8, "text/xml")      dim credentials = new networkcredential(username, password)     dim handler = new httpclienthandler() {.credentials = credentials}      using client = new httpclient(handler)          using response = client.postasync(apiurl, content).result             return await response.content.readasstringasync()         end using      end using  end function 

this how being used:

for each listitem in listobj ... result = xmlexchangeobj.postsecurexmlasync(username, password, payload).result ... next 

i expecting control return each loop while waiting replies web service, based on break points seems running synchronously.

when you're working async, don't want call wait or result. instead, should use await. see 1 result in postsecurexmlasync:

using client = new httpclient(handler)     using response = await client.postasync(apiurl, content) ' changed await         return await response.content.readasstringasync()     end using end using 

and there's 1 when call async method:

result = await xmlexchangeobj.postsecurexmlasync(username, password, payload) 

this mean calling method must async, means methods call that method should use await, , must async, etc. "growth" through code normal. allow async grow until reach natural stopping point (usually event handler, can make async sub).


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -