Would like to confirm something related to he ConfigureAwait. As far a i read by default Configureawait is set to true. However it can be set to false. There is something people saying that when it's true (default) then all code after await will be run within context, and if is set to false it will not. So according to the example if i set it to false then DoIndependentWork would fail to write to a control unless i do Dispatcher as it will not run on context means on UI thread in this case, and if true it will. Is it right thinking? So generally saying when false is set all after await will not be running on main thread (not within context) so for example access to the controls will be not possible (unless dispatcher of course). Is it right? I used to use think of it like if it's WIndows forms, then context is UI thread, so simply saying if i set false means it will fail to access controls, if true it will work. Is it all rght thinking? And what about console application/windows service, what is the context for that and does it really matter what i set either true or false?
Async Function AccessTheWebAsync1() As Task(Of Integer)
Dim getStringTask As Task(Of String) = New HttpClient().GetStringAsync("http://msdn.microsoft.com")
Dim urlContents As String = Await getStringTask.ConfigureAwait(false)
DoIndependentWork()
Return urlContents.Length
End Function
Sub DoIndependentWork()
If ResultsTextBox.Dispatcher.CheckAccess() Then
Write()
Else
ResultsTextBox.Dispatcher.Invoke(New Action(AddressOf Write))
End If
'ResultsTextBox.Text &= "Working . . . . . . ." & vbCrLf
End Sub