Dealing with broken ActiveX controls

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I routinely have to connect to ActiveX servers and call various methods. The problem is said control is very buggy and often times I will call a function only to have it never finish executing thus locking my code. I've left it sitting for minutes at a time hoping something will finally finish but it never does. There are no exceptions being thrown, it just locks up.

I'm accessing the control through a VB.NET class that instantiates a copy of the ActiveX object and provides access to the underlying functions of the control.

What I'm wondering is if there are any ways to use a timeout for calling functions that belong to the ActiveX control. For instance, if the method call doesn't exit within 5000ms give up and perhaps try again or even close the ActiveX control and re-open it.

 

nickbits

Diamond Member
Mar 10, 2008
4,122
1
81
I think you'd have to spawn a new process that makes the ActiveX calls. Then if it doesn't exit after some time you kill it and try again. You might be able to get the same effect using threads but there could be more side effects.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: nickbits
I think you'd have to spawn a new process that makes the ActiveX calls. Then if it doesn't exit after some time you kill it and try again. You might be able to get the same effect using threads but there could be more side effects.

That's what I was hoping to avoid :(

That will not fly given the nature of the program, ideally I would be calling said functions of the ActiveX control at least several times per second and I'm sure all the overhead of creating/destroying all those processes would be detrimental.

The biggest problem I have is that when this control locks up it throws the rest of the code into a deadlock, I guess I can isolate the control in it's own thread and have the thread report back every so often and if it doesn't respond for a given amount of time destroy it and restart. The whole idea is that we receive data from the control and then respond by calling certain functions in the control and if the function call locks up then the data stops coming through.

So frustrating trying to interface to broken code :(