473,408 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to send message to another instance of application ?

I want my application to be able to load most components it uses at user
logon (f.e. by running "prog.exe /startup") and create a NotifyIcon to
show up in tray.
Now when i load the prog.exe second time (without parameter) it should
detect that an instance is already running and tell it to show the main
form of the application (i need this to reduce application startup
time). Then the second instance should exit.
So far i've made a detection, if another instance is already running, by
using Process.GetProcessesByName.

The problem is how do i tell the first run prog.exe (from the second
one) to show all the forms ?
Using threading, appdomain (getdata?), writing lock file ?

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de
Nov 21 '05 #1
5 2240
See Remoting.

"Adam Nowotny" <ad**@logosoft.pl> wrote in message
news:41******@news.home.net.pl...
I want my application to be able to load most components it uses at user
logon (f.e. by running "prog.exe /startup") and create a NotifyIcon to
show up in tray.
Now when i load the prog.exe second time (without parameter) it should
detect that an instance is already running and tell it to show the main
form of the application (i need this to reduce application startup
time). Then the second instance should exit.
So far i've made a detection, if another instance is already running, by
using Process.GetProcessesByName.

The problem is how do i tell the first run prog.exe (from the second
one) to show all the forms ?
Using threading, appdomain (getdata?), writing lock file ?

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de

Nov 21 '05 #2
CJ Taylor wrote:
See Remoting.


Thought about it, but it seems to be a bit too serious for a single
"signal", like "hej, show the forms, i'm getting outta here" :D

I just noticed that instead of using the Process class to detect other
instances (the ProcessName property takes several seconds to complete on
the first run) i can create an instance of Threading.Mutex object and
look at the last parameter passed by reference...thought maybe using the
Threading namespace would help in this case.

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de
Nov 21 '05 #3
>
See Remoting.
Thought about it, but it seems to be a bit too serious for a single
"signal", like "hej, show the forms, i'm getting outta here" :D

I just noticed that instead of using the Process class to detect other
instances (the ProcessName property takes several seconds to complete on
the first run) i can create an instance of Threading.Mutex object and
look at the last parameter passed by reference...thought maybe using the
Threading namespace would help in this case.


Yeah, I looked originally in the threading namespaces but found it couldn't
do the interprocess communication. I completely forgot about Mutex's, which
is silly because I used that exact idea a few months ago. =)

Does remoting seem a little excessive? Sometimes, its really not though. I
know it's buried deep in there but its really useful for something like
this. (I do miss DDE Link's from VB6 which took care of all the inter
process communication for you). You could write to a file and have a file
system watchter respond, but you limit yourself there to Win 2000+ only.
Not that there are a massive amount of machiens running NT 4/Win9x. But
there still are a few (i.e. my shop). And they can't run that.

So remoting, its safe, not that hard to do, and about 1,000 examples on here
and other resources such as DevX or Planet Source Code. Or MSDN for that
matter.

In the end, remoting is pretty lightweight from what I've seen (I've only
used it to send a few messages back and forth. Hasn't shown any problems in
my memory profiler. No delays (same machine) etc...

Anyways, hope I helped a little.

Good Luck,
CJ

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de

Nov 21 '05 #4
CJ Taylor wrote:
Does remoting seem a little excessive? Sometimes, its really not though. I
know it's buried deep in there but its really useful for something like
this.


Won't there be any firewall problems, like ZA reporting about a
communication ? ;-)
I'll try to figure out something and report if find something...or else
just use remoting.
Anyway, thanks for help :)

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de
Nov 21 '05 #5

"Adam Nowotny" <ad**@logosoft.pl> wrote in message
news:41******@news.home.net.pl...
CJ Taylor wrote:
Does remoting seem a little excessive? Sometimes, its really not though. I know it's buried deep in there but its really useful for something like
this.
Won't there be any firewall problems, like ZA reporting about a
communication ? ;-)
I'll try to figure out something and report if find something...or else
just use remoting.
Anyway, thanks for help :)


If its inside the same machine it should use the local loopback, which ZA
and other personal firewall software should ignore. Also uses HTTP which
again most software is taught to ignore/allow.

If I'm wrong on this someone correct me.

-CJ

--
Adam Nowotny
JID: da**@chrome.pl
GnuPG key 0x42D56D98 at hkp://blackhole.pca.dfn.de

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: trint | last post by:
How can I send from myApp, over the internet with c#.net, a message to another instance of myApp?? Like Yahoo or MSN? Thanks, Trint
2
by: PJ Olson | last post by:
I have an app that allows only one instance to run at a time. I have a file extension associated with this app and would like to pass a running instance the file name if a user double-clicks the...
6
by: harvie wang | last post by:
Hi, How to send a message to every window(include child window), I use SendMessage ,but It can't do that. class frmA { public const int WM_test = 0x400 + 1; protected override void...
5
by: zorhel | last post by:
Hi. My clients will be IE, Mozilla and Opera in a Windows and *nix OS. So, my web app need to, from a server, send messages to a specific client (browser), send messages for all clients,...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
15
by: cj | last post by:
How can I get a button in VB to send the contents of a text box via email in a manner similar to the "Send To\Mail Recipient" functionality that you can select via right clicking a file in Windows...
6
by: ShieldsJared | last post by:
Hello all, I've been working on an application for a while now and have now come to a standstill. I have an application that I intend to have stored on a file server (developed in C#), which...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
2
by: Mesan | last post by:
Hello everyone, Thanks to many useful posts in this newsgroup and others, I've been able to come very close to something I've been wanting to do for a very long time. I've figured out how to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.