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
Solved

VB.net Application Talking to Another

Posted on 2011-03-24
9
618 Views
Last Modified: 2012-06-27
I have a situation where I have a third part provided application that can launch programs passing data from the UI screens to it as parameters. They have no other way to interact with data so this is what I have to use.

I have an application that is launched with the passed data on teh command line and it does its thing. The problem is I need a way to have a sort of "controller" application that will detect if the application is already open.. and if it is send the new info to the application so it can accept the new data. I dont want to close and reopen the application I prefer to just pass the new information and have the application change to this new data.

So what I need is to develop a calling application that will check to see if the app is open.. if it is not then open passing my info. If it is open I need to have this caller send this info to the currently running process and have that appilcation act on the new data.

Can anyone direct me here... is this WCF, sockets, or is there a much easier way to go about doing this? I have considered just using the registry as a staging ground and have it check every x ms and do something if the value changes.. sort of crappy idea though.
0
Comment
Question by:NTGuru705
9 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35211721
"I have an application that is launched with the passed data on teh command line and it does its thing."

Do you have the SOURCE CODE for this application?
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 35211832
you can start a program / process by calling process.start and provide any command  line options to it.

You can also use the invoke (as in p.invoke()), and with this you can keep in memory the process ids etc
0
 
LVL 28

Expert Comment

by:Ryan McCauley
ID: 35212408
If you have the source code for this application, you can set it up to receive wcf messages - just open a wcflistener when the application launches and then your "client" can send wcf messages to that endpoint whenever it wants to refresh the app. There are a number of examples online (google "wcf communications tcp port"), so I won't try to reproduce one here.

Another option is to have the "server" app create a filewatcher and watch some folder. When your "client" wants to send an update, it writes it to a file and the watcher sees it, picks it up, and processes it.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 1

Author Comment

by:NTGuru705
ID: 35212428
No I dont have source for the application I am integrating with but yes I have the source for the app I am opening from this program.

So there is a program lets call it Program A.
It allows me to launch another program from custom menu commands and pass as parameters information from the present working screen in that application.

THe application I am calling is Program B - I have the source.

I need to write Program C which can be called from Program A to send info to Program B if it is already open and if not just spawn Program B. I want the application Program B to stay open and just pass the new parameters to it.  I think WCF is a great option but the file watcher is a great idea too because there is no excessive "reading" going on. That may be my fastest route because I have experience with that. I want to stay away from TCP sockets if I can because it will be running on a terminal server and I dont want to have to manage ports and such.

I think I will go with the file watcher and see how it responds. If it is not fast enough I can try to figure out the WCF stuff.
Thank you for your help
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35212547
There is an easier solution using the Application.StartupNextInstance() event:
http://msdn.microsoft.com/en-us/library/b9z4eyh8(VS.90).aspx
http://msdn.microsoft.com/en-us/library/w3xx6ewx(VS.90).aspx

Just check the "Make single instance application" box in Project --> Properties.

Now you can use "Process.Start(ProcessBFullPathFilename, ProcessB_Parameters)" regardless of whether Process B is running or not.

If Process B is not running then it will get the Startup() event.
If Process B is already running then it will get the StartupNextInstance() event.

There will only ever be ONE instance of Process B running though.
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 35212625
In the make single instance application... that applies only to the current session right?
So on a terminal server more than one user could run it but per session only one - am i understanding that right?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35212632
Not sure about the sessions issue as I don't work them...sorry.
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 35212639
I seem to be getting this error:


Error      1      Event 'StartupNextInstance' cannot be found.
Private Sub MyApplication_StartupNextInstance( _
ByVal sender As Object, _
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
        Dim inputArgument As String = "/input="
        Dim inputName As String = ""

        For Each s As String In e.CommandLine
            If s.ToLower.StartsWith(inputArgument) Then
                inputName = s.Remove(0, inputArgument.Length)
            End If
        Next

        If inputName = "" Then
            MsgBox("No input name")
        Else
            MsgBox("Input name: " & inputName)
        End If
    End Sub

Open in new window


0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35212666
You have to put it in the a special place.

Click on Project --> Properties.
Then click on the "View Application Events" button in the bottom right.
Across the top of the IDE, change the two dropdowns:
    Left DropDown: "MyApplication" --> "(MyApplication Events)"
    Right DropDown: "(Declarations)" --> "StartupNextInstance"
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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