I have a network lib I am using. All calls are asynchronous - that's good. However, I need to make SOME calls synchronously - in that I want the program (or at least the current thread) to stop and wait for the response (or time out). This is for things like filling in a form for a user to read and make selections...
There are all kinds of ways such as a simple spinwait
Expand|Select|Wrap|Line Numbers
- Dim sw as new Stopwatch
- sw.start
- Do until bsomething = true or sw.elapsedmilliseconds >= TIMEOUT
- Threading.thread.sleep(25)
- Application.DoEvents
- Loop
- If sw.Elapsedmilliseconds > TIMEOUT then
- 'notify user of timeout
- Else
- 'process the data that arrived inside the asyc function
- End if
Is this a place where a callback makes sense (I've not done any callbacks yet...)?