Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier22-Mar-17 1:13
professionalNathan Minier22-Mar-17 1:13 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
ArunHanu22-Mar-17 1:43
ArunHanu22-Mar-17 1:43 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Pete O'Hanlon22-Mar-17 2:03
mvePete O'Hanlon22-Mar-17 2:03 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier22-Mar-17 2:08
professionalNathan Minier22-Mar-17 2:08 
SuggestionRe: How to write a generic code to make async call to Rest Service Pin
Richard Deeming22-Mar-17 2:23
mveRichard Deeming22-Mar-17 2:23 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
ArunHanu22-Mar-17 3:06
ArunHanu22-Mar-17 3:06 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier22-Mar-17 3:53
professionalNathan Minier22-Mar-17 3:53 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Richard Deeming22-Mar-17 4:20
mveRichard Deeming22-Mar-17 4:20 
No, sorry, that's not correct.

The await client.GetAsync(url) and await response.Content.ReadAsStringAsync() calls will not block the current thread. They will sign up the rest of the method as a continuation, which will be invoked when the returned Task<T> has completed.

The GetAsync and ReadAsStringAsync calls (eventually) use an IO completion port to receive notification when the request has completed.

That's the whole point of async / await. Smile | :)

The only thing your example is doing differently is that it's using a background thread to run the very first part of the method - the call to GetAsync. As a result, the rest of the method will not run on the captured execution context from the caller of RefreshData. But you could achieve the same result by adding .ConfigureAwait(false) to the end of the GetAsync and ReadAsStringAsync calls.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier22-Mar-17 4:59
professionalNathan Minier22-Mar-17 4:59 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Richard Deeming22-Mar-17 5:26
mveRichard Deeming22-Mar-17 5:26 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier22-Mar-17 6:06
professionalNathan Minier22-Mar-17 6:06 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Richard Deeming22-Mar-17 6:16
mveRichard Deeming22-Mar-17 6:16 
GeneralRe: How to write a generic code to make async call to Rest Service Pin
Nathan Minier23-Mar-17 1:12
professionalNathan Minier23-Mar-17 1:12 
QuestionWindows 10 Thin Border Cause a space issue compare to windows 8 Pin
Member 979968321-Mar-17 20:12
Member 979968321-Mar-17 20:12 
AnswerRe: Windows 10 Thin Border Cause a space issue compare to windows 8 Pin
Gerry Schmitz23-Mar-17 17:52
mveGerry Schmitz23-Mar-17 17:52 
QuestionGetting COM port list ? Pin
Member 245846721-Mar-17 16:44
Member 245846721-Mar-17 16:44 
AnswerRe: Getting COM port list ? Pin
Richard MacCutchan21-Mar-17 23:11
mveRichard MacCutchan21-Mar-17 23:11 
GeneralRe: Getting COM port list ? Pin
Member 245846722-Mar-17 15:28
Member 245846722-Mar-17 15:28 
AnswerRe: Getting COM port list ? Pin
Ralf Meier23-Mar-17 1:26
mveRalf Meier23-Mar-17 1:26 
AnswerRe: Getting COM port list ? Pin
Gerry Schmitz23-Mar-17 17:51
mveGerry Schmitz23-Mar-17 17:51 
QuestionDCMTK help needed Pin
Tetsuo_DarkK21-Mar-17 4:49
Tetsuo_DarkK21-Mar-17 4:49 
AnswerRe: DCMTK help needed Pin
Richard MacCutchan21-Mar-17 4:56
mveRichard MacCutchan21-Mar-17 4:56 
QuestionQuick MEF Question Pin
Kevin Marois20-Mar-17 7:04
professionalKevin Marois20-Mar-17 7:04 
AnswerRe: Quick MEF Question Pin
Richard MacCutchan20-Mar-17 23:02
mveRichard MacCutchan20-Mar-17 23:02 
GeneralRe: Quick MEF Question Pin
Kevin Marois21-Mar-17 4:03
professionalKevin Marois21-Mar-17 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.