Solved

Pass data between 2 VB.NET applications on the same machine

Posted on 2013-12-03
16
1,035 Views
Last Modified: 2014-01-06
Hey,

I am looking for a solution that will allow me to pass simple string, or maybe a few basic values from one application to another that is running on the same machine.   There won't be a huge amount of data exchanged and it will be user initiated, so the frequency will be fairly low ( maybe once every few seconds).  And it will always be on the same machine.  I have looked around the web and found a couple different approaches such as windows messaging, remoting, or just reading/writing.   All of the articles were all pretty old though (pre 2009).  

Is there a solution that is better than others or simpler to implement.   And if so, can you point me in the direction of a good example.

To give a better picture of what I am trying to accomplish.   My end goal it to add functionality into application "A", so when the user clicks a phone number it will send that number to another application that will initiate a call.  So I would pass the persons name and phone number from Application A to application B.


Thanks in advance...
0
Comment
Question by:MRS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
16 Comments
 
LVL 4

Expert Comment

by:bcolladay
ID: 39693925
Does program B have to be running or can program B start an instance?

If it can be started on demand, you could use command line arguments.
0
 

Author Comment

by:MRS
ID: 39693936
Program B  would already be up and running.  And it would need to continually receive new information to process as it while it runs.
0
 
LVL 4

Expert Comment

by:bcolladay
ID: 39693961
Assuming they are networked, udp might work as well, I've never done it, but see if this looks like a solution:

http://www.codeproject.com/Articles/8877/UDP-Send-and-Receive-using-threads-in-VB-NET
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:MRS
ID: 39693983
That seems like more then I need as all my interaction will take place on a single machine.
0
 
LVL 4

Expert Comment

by:bcolladay
ID: 39693992
Then how about having program A write a file with the data to pass, in a shared location. Tell Program B to read the file(s) every x seconds, consume the data from the file, then delete it.
0
 

Author Comment

by:MRS
ID: 39694015
that was one of the solutions that I had seen on the web, just didn't seem very elegant of a solutions compared to some of the newer technologies.  But old doesn't necessarily mean bad.  I will give that a shot and see how it performs.
0
 
LVL 84
ID: 39694102
Or use a database, like SQLite or SQLSvrCE, and write data from ProgramA, and read it from ProgramB.

Of the Registry.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39694422
0
 
LVL 12

Accepted Solution

by:
ktaczala earned 500 total points
ID: 39694486
You can use filewatcher to check for a file showing up in a folder, then act upon it.  I would run that as a backgroundworker task.  Filewatcher Rocks!! Nothing would happen in the second app until a file shows up in the specified folder, I would check for a particular filename so there's no chance of a file being put there accidentally and being in the wrong format.  By putting the filewatcher in a backgroundworker thread the app will not lose responsiveness.
0
 

Author Comment

by:MRS
ID: 39695501
ktaczala,

That is exactly how I implemented it and seems to work OK as expected.  I am a little concerned that this approach will handle the volume and run into an IO bottleneck.  You mentioned running the FSW in a different thread.  It seems like it is in it's own thread by default as I have to use delegates to update the form.  Was there something special you had in mind?

Lastly,  Has anyone used WCF for something like this in the past?  That seems to be the "recommended approach" from what I have read online, but most of the examples deal in hosted services or web services.  This would be more of a client/server type of scenario.

Thanks again for all the input from everyone
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39695578
You're right about filesystemwatcher, it was late when I posted that.  it does run on it's own thread.

Here's Some info on what issues people have come across with FSW;
http://stackoverflow.com/questions/239988/filesystemwatcher-vs-polling-to-watch-for-file-changes

do a search for "filesystemwatcher or WCF" you'll get lots of good info.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39695749
there is too much overhead for FSW when it is for short messages on the same machine. you should really consider the MemoryMappedFiles
0
 

Author Comment

by:MRS
ID: 39696100
emoreau,

Is there an way to trigger an event when the shared memorymappfile is updated.  Much like the way a FSW triggers an event, or would I have to write something that would keep looking for changes based on a timer or something?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39696223
I don't think you can because the connection as to be initiated. Maybe in your case you could use a timer
0
 

Author Comment

by:MRS
ID: 39696231
Any thoughts on using WCF? Seems like it has all the core components required to achieve this task....
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39696266
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question