VB.NET: What happens if I run CPU-bound code using Await?

Viewed 111

I am trying to understand async/await. I understand that you should not Await a CPU-bound method, but to help my understanding I am curious what happens if you do. Consider:

Public Async Function DoSomeTasks()
    Await LongRunningCPUBoundMethod1()

    LongRunningCPUBoundMethod2()
End Function

Public Async Function LongRunningCPUBoundMethod1() As Task
     ' Do stuff synchronously
End Function

Public Sub LongRunningCPUBoundMethod2()
     ' Do stuff synchronously
End Sub

How will the Task Scheduler handle the CPU resources? In what order will these methods execute? Will LongRunningCPUBoundMethod1 or LongRunningCPUBoundMethod2 execute first?

2 Answers
Related