Sigh, I really struggle with this whole Asynchronous thing. I have a routine that runs DbRequestmanager. Works Fine but I wanted to run it from more than one place so I moved it to a Module. That didn't work because it requires an object to initialize the callback (Me) so I moved it to a classmodule.
That's fine except the problem is I need to disable a button when the routine is run manually (not in the background). The only way I found to do this is to re-enable the button in the JobDone routine after the final update. BUT you can't directly reference a button in an activity from a class module so I wrote a sub in the activity to re-enable the Button and use call subdelayed to re-enable the button. Then I realized I don't want to be queuing up a bunch of messages to start an activity I am not currently using so I added parameter to the Call to tell the routine whether it NEEDS to run the Callsubdelayed. (I hope this makes sense.)
So what is my question? Is this the cleanest way to do this? I thought about a DoEvents loop after the call that would wait for a flag but that is just ugly. I really don't want to duplicate a whole bunch of code just to make it easier to disable/enable a button. In VBA if you shell out to run a command you have an option to wait for the called routine to finish or continue on. I am just a dumb database programmer so I have no idea how hard this would be to implement but a WAIT option on a call would sure be wonderful addition. The program would wait the call was completed before continuing.
That's fine except the problem is I need to disable a button when the routine is run manually (not in the background). The only way I found to do this is to re-enable the button in the JobDone routine after the final update. BUT you can't directly reference a button in an activity from a class module so I wrote a sub in the activity to re-enable the Button and use call subdelayed to re-enable the button. Then I realized I don't want to be queuing up a bunch of messages to start an activity I am not currently using so I added parameter to the Call to tell the routine whether it NEEDS to run the Callsubdelayed. (I hope this makes sense.)
So what is my question? Is this the cleanest way to do this? I thought about a DoEvents loop after the call that would wait for a flag but that is just ugly. I really don't want to duplicate a whole bunch of code just to make it easier to disable/enable a button. In VBA if you shell out to run a command you have an option to wait for the called routine to finish or continue on. I am just a dumb database programmer so I have no idea how hard this would be to implement but a WAIT option on a call would sure be wonderful addition. The program would wait the call was completed before continuing.