I've got a vs2010, 4.0 vb.net, WinForms app calling AttemptLogin on a form load event.
I want to avoid blocking the form load if possible and I was hoping the tasks and continuation stuff in 4.0 would be the right way to go as I could run the main task on the default scheduler and the continuation on fromcurrentsynchronisationcontext but although I've got the OnAttemptLogin working I can't get my OnAttemptLoginCompleted function in the continuation to be called.

I think it's because the OnAttemptLogin returns a "RunToCompletion" task so the continuation never gets called. But I don't know how to deal with that, I've tried numerous things but I've now confused myself so much I'm pretty much mashing keys. Can anyone offer any advice? Am I simply doing it wrong or have I got the wrong idea all together?

Here's what I have so far, the OnAttemptLogin works as I would expect it to, but it then never calls the LongRunning tasks continuation. 

Please note: I **can't use await** as I'm in vs2010 .net4.0 so I'm stuck with ContinueWith.

```
Public Sub AttemptLogin(OnAttemptLoginCompleted As Action(Of Task(Of HttpResponseMessage)))
    Try
        Dim LongRunningTask As Task(Of HttpResponseMessage) = Task.Factory.StartNew(Function()
                                                                                        Return OnAttemptLogin()
                                                                                    End Function, TaskScheduler.Default)

        Dim UITask As Task(Of HttpResponseMessage) = LongRunningTask.ContinueWith(Sub(t)
                                                                                      OnAttemptLoginCompleted(t)
                                                                                  End Sub, TaskScheduler.FromCurrentSynchronizationContext)
        LongRunningTask.Wait()
    Catch ex As AggregateException
        ' nom nom nom
        ' do something useful
    End Try
End Sub

Private Function OnAttemptLogin() As Task(Of HttpResponseMessage)
    Dim aClient = New HttpClient()
    Using (aClient)
        ' CREATE REQUEST
        aClient.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
        aClient.DefaultRequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(String.Format("{0}:{1}", CallingDTO.Email, CallingDTO.Password))))
        UserQueryDTO.UserName = UserDTO.Email
        UserQueryDTO.Password = UserDTO.Password
        Dim url As String = DnnRequest.GetUrl(Credentials.HttpAlias, cstModuleAssembly, "User", "CanLogin", False)

        ' POST REQUEST
        Dim p As Task(Of HttpResponseMessage) = aClient.PostAsJsonAsync(url, UserQueryDTO).ContinueWith(Function(x)
                                                                                                            ' READ RESPONSE
                                                                                                            Dim r = x.Result.Content.ReadAsAsync(Of HttpResponseMessage)()
                                                                                                            r.Wait()
                                                                                                            Return r.Result
                                                                                                        End Function)
        Try
            p.Wait()
        Catch ex As Exception

        End Try

        Return p

    End Using
End Function

```