Link to home
Start Free TrialLog in
Avatar of kjfoley
kjfoley

asked on

Communicating between apps

Hi,

I have an application that does some terminal emulation.  The problem is that when I'm trying to debug other areas of the application, I lose the ability to have my terminal keep functioning.  I figured I needed to break these into two applications and send commands from the main one to the terminal as needed.

How can I make some of the terminals functions public and then reference them from the main app?  I read that compiling them as ActiveX exe's would do the trick but haven't had any luck.

I'm looking for help figuring out how to do this.  

kjf
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RMatzka
RMatzka

There are several ways to exchange information between applications. One is have them as ActiveX Server and Client, Another is to use the WinSock OCX control for communication between standard apps, a third is using Windows Messages, and there are more.

The ActiveX technique is the simplest among these for VB developers to use. I don't know which kind of problems you encountered when you tried it. Assuming your terminal application were an ActiveX client and the other functionaliy were an ActiveX server, one problem could be that while you are stepping through a server function which has been called from the client, the client application would be blocked, and that is what you don't want. To avoid this kind of problem, you would have to code the server functions asynchronically. That is, when the client calls a server function, the server does nothing but starting a timer (with, say, 50 ms) and then returns immediately. Only when the timer fires, the actual work of the function is executed. If you want to return function values or other information, you need to use some kind of callback mechanism, so the server can call back to the client and tell it what the results of the function are.

But even with this asynchronous ActiveX server technique, you could experience client blocking while you are debugging the server, since the client would probably try to invoke some other server function. This function could not respond, even if coded asynchronously, as long as you are debugging something else.

For this reason you should consider using Windows Messages or Sockets. I would prefer the Sockets approach. It is more natural and, in addition, allows you to have the two applications running on different machines. You use the WinSock OCX to establish a TCP-IP connection between the two apps, and then you can send strings in both directions. This approach is asynchronous by its very nature. In addition to the move from synchronous to asynchronous function calls, you now need to do some extra work for converting your function calls to string sending procedures and converting strings received in function calls. In the long run, this approach will pay itself off.
Avatar of kjfoley

ASKER

Thank you both for the suggestions.  

I would have liked to implement the ActiveX solution but don't understand it enough to do it without spending some time to learn more about it.  Unfortunately, I needed this ASAP for testing my application.

Richie, this worked perfectly.  I broke my application into 2 parts and have them communicating back and forth.  This way I can test code in one part while the other (thats doing terminal emulation) continues to run uninterrupted.

Thanks again.

kjf
You are welcome. Most of the time, we don't need a cannon to kill a fly, just a little newspaper
;)
Cheers and thanks for "A" grade.