Archived Forum Post

Index of archived forum posts


Async callback in VB6

Dec 04 '15 at 10:09

If you have WithEvents and use the SyncronousRequestAsync method it will crash the IDE when you attempt to write LastErrorText to the debug window. I assume the idea is that you wouldn't use WithEvents with Async so I have removed them for now. (that took up my morning to find that issue) Am I correct? Or is it buggy?


When a method is running asynchronously, it is running in a background thread. If callbacks are utilized, then the callback is occurring in a background thread (it is not in the foreground thread). The solution is to tread lightly and carefully because what is possible or not possible depends on the programming language and runtime environment. For example, in .NET you would need to do this:

Your event callback method might simply update a variable within your code such that your foreground thread can periodically check for changes.