Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb6 kill/skip CreateObject call

Can someone suggest how I can terminate or go around a CreateObject operation that occasionally takes minutes to finish? Basically I have this code:

Set m_Zeacom = CreateObject("QmCOM.QIntegrate")

that works instantly most of the time, but for some users may take minutes (why - is not important in this context). So what I'd like to do is to set a time limit on CreateObject execution and either kill it or detach my app from it. I've played around with DoEvents trying to proceed with the other code while CreateObject is hanging, but without any luck.

like image 866
user3042375 Avatar asked Mar 21 '26 04:03

user3042375


1 Answers

Another option is to have the CreateObject call in an ActiveX EXE which runs outside of your process.

  • So say the we call that ActiveX EXE OutOfBounds.Factory.
  • You implement a Callback interface in your class something like IListener.Callback which accepts an object as part of the callback.
  • You create an OutOfBounds.Factory class.
  • The out of bounds factory class has a method call GetQmCom which accepts an IListener callback.
  • The GetQmCom methods in your ActiveX EXE returns immediately, but in the background (say in a timer event) it creates the object, once the object is created it calls the callback passing in the object created.
  • Disadvantage of that is the other process owns the object so you end up with cross process calling when you use it in you process. If you don't call it much, you can probably get away with that.
  • Disadvantage, all your code would need to deal with not having an actual instance of the object, as it's non deterministic as to when it arrives from the ActiveX EXE (but you probably need to do that anyway if you are willing to skip it or time out).
  • Advantage, using an ActiveX EXE (dependning on what way you code it) you can cache/share instances as required.

I don't have VB6 any more otherwise I would knock up an example for you.

You may find this MS link about ActiveX EXE's useful http://msdn.microsoft.com/en-us/library/aa262306(v=vs.60).aspx

like image 166
Bigtoe Avatar answered Mar 23 '26 07:03

Bigtoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!