Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Communicating between vb programs

Status
Not open for further replies.

bez999

Programmer
Oct 3, 2003
99
0
0
GB
Hello
I have 2 vb.net programs that use a common DLL and I need to serialise its use. Is there a way that 2 programs could access a common resource to see if the resource is free?
Specifically, I am using the Betfair interface which must be restricted to a certain number of calls per minute so what I want to do is have a way of setting a flag to say it's in use and clear the flag when it is free.
Hope that makes sense.
Thanks for any help.


Regards
Chris Bezant
 

Off the top of my head, you could use the System.IO.File class to do this. Set up both apps to use the File class to monitor a directory. Before accessing the DLL, have the program check the directory for the existence of a file - System.IO.File.Exists(FilePath) - that indicates the DLL is already in use. If the file is not found, the app creates the file (to let the other app know the DLL is in use), does its thing, then deletes the file (to indicate the DLL is no longer in use). Do the same in the second app.

Of course, you could do the same thing with a database, just writing and removing records from a table that serves the same purpose as the directory and file above.

The problem with both of these methods is if one program crashes before removing the lock file (or record), the second program will never run because the lock won't be removed. You could use a time limit or something to force removal of the lock, but this could interrupt a long process.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks for the response.
I thought about this technique but I wondered if it would be fast enough if the there were ten calls per second. At the moment I am nowhere near that frequency but I am envisaging having maybe 5 programs all needing to serialise through this connection. That is why I will eventually need this busy flag technique.
Any thoughts on speed?


Regards
Chris Bezant
 

Hmmm...I wouldn't trust this method in the case of ten calls per second.

Is there any particular reason these have to be different programs? Could you make just one program that makes the requests to the dll? Perhaps a middle-tier that could take requests from the other programs and queue them?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
They have to be separate programs - too complicated to explain but I have found a solution. After a trawl on the net last night I saw a keyword that triggered instantly in my brain. In another lifetime I used to program on OS/2 and when I saw this item it all came flooding back - well in principle anyway.
The answer for me is IPC Inter Process Communication. I have an example zip that gave me the basis on which to build a two way communication that will suit my purpose.
I don't know how to attach a file to this post but if you are interested I can forward the small zip to you.
Thank you for taking the time to help me with this :eek:)

Regards
Chris Bezant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top