I have to admit I don't really understand this async calling
Below code seems to "fail for me or better is not behaving as I would expect
I'm calling
WAIT_MOVING()
from my main thread and would like to wait in a loop running in a new task to wait for
IsMoving
to change state
The main idea is for the main thread to stay responsive but wait for the task to finish ...
This does not seem to happen
- The task starts and does it's job but the main thread keeps on going - as is not waiting for the task to finish.
Again the main task is to keep the main thread responsive while we wait for the
IsMoving
flag to be set.
Any ideas why this is not working as expected ?
Friend Async Sub WAIT_MOVING()
Dim AbortWait As Boolean = Await Task.Run(Function()
Return WaitFor_Moving()
End Function)
If AbortWait Then
doSomething
End If
End Sub
Friend Function WaitFor_Moving() As Boolean
While Not IsMoving
If MC_Alive = False then
Return True
endif
End While
Return False
End Function
What I have tried:
Multiple variations of Async calls non seemed to have produced the "expected "result for me