Hi All,
I am developing a small utility, and have run into a small challenge.
The util is used for performing operations on a bunch of files, and it
can be triggered from the right-click menu when you click on a file.
My problem now is, if the util is already running, I want to stop a
new instance from spawning, and, at the same time, pass the parameters
from the soon-to-be-despawned instance, to the main instance.
My solution at this moment is to open a socket on LocalHost when the
first instance starts, and then on the following, check if something
is bound in the specific port, and then pass the parameters via TCP.
But, can this be done more elegantly?
The reason i'm asking is that this approach seems very "hacky" to me,
but, on the other hand, it works, and I haven't been able to make it
loose parameters or misbehave in other ways.
/Peter 4 1512
On Sep 26, 4:02 pm, Peter Reinhold <pe...@reinhold.dkwrote:
Hi All,
I am developing a small utility, and have run into a small challenge.
The util is used for performing operations on a bunch of files, and it
can be triggered from the right-click menu when you click on a file.
My problem now is, if the util is already running, I want to stop a
new instance from spawning, and, at the same time, pass the parameters
from the soon-to-be-despawned instance, to the main instance.
My solution at this moment is to open a socket on LocalHost when the
first instance starts, and then on the following, check if something
is bound in the specific port, and then pass the parameters via TCP.
But, can this be done more elegantly?
The reason i'm asking is that this approach seems very "hacky" to me,
but, on the other hand, it works, and I haven't been able to make it
loose parameters or misbehave in other ways.
/Peter
If you've got an overactive QA person, one who likes to double click
on things as fast as they can to see if anything breaks, you might
want to use a mutex (use an app-specific, unique name). The first
instance would hold the mutex until it exits; anything else would
queue up the request via TCP.
Remoting is another way to handle the interprocess communication but
if the parameters are relatively simple it might be overkill...
want to use a mutex (use an app-specific, unique name). The first
instance would hold the mutex until it exits; anything else would
queue up the request via TCP.
It might be a good idea to implement a combination of a mutex and then
if that is set, deliver parameters via TCP
Remoting is another way to handle the interprocess communication but
if the parameters are relatively simple it might be overkill...
I actually checked out remoting during my first analysis, and I deemed
it to be overkill for passing a filename between two applications.
/Peter
On Sep 26, 10:15 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
The general concept is actually very sound, IMO, as this is exactly what
the WindowsFormsApplicationBase class in the Microsoft.VisualBasic namespace
does.
Ok, thats nice to hear :)
Thanks for the links Nicholas, i'll check them out at once.
/Peter
Peter Reinhold wrote:
>want to use a mutex (use an app-specific, unique name). The first instance would hold the mutex until it exits; anything else would queue up the request via TCP.
It might be a good idea to implement a combination of a mutex and then
if that is set, deliver parameters via TCP
I agree. I think that's what Arnshea was suggesting.
>Remoting is another way to handle the interprocess communication but if the parameters are relatively simple it might be overkill...
I actually checked out remoting during my first analysis, and I deemed
it to be overkill for passing a filename between two applications.
One advantage remoting might have is to avoid the issue of what to do if
the port you've selected for your socket is already in use by something
else. I haven't used it myself, but I assume it uses a communication
mechanism that ensures a connection between the two endpoints can always
be created.
If you already have some mechanism for having the port auto-selected,
but still discoverable by subsequent instances of the application, then
I'd agree remoting is probably overkill. Otherwise, you might consider
it still. :)
Pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Darren Dale |
last post by:
Hello,
def test(data):
i = ? This is the line I have trouble with
if i==1: return data
else: return data
a,b,c,d = test()
|
by: Mike |
last post by:
Looking to find any information on how to properly configure multiple
instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking
for information on how the multiple instance settings...
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing...
|
by: Nikolay Petrov |
last post by:
How can I return multiple values from a custom function?
TIA
|
by: Nathan Sokalski |
last post by:
I am a beginner with AJAX, and have managed to learn how to use it when
passing single parameters, but I want to return more than one value to the
client-side JavaScript function that displays it....
|
by: Achim Domma |
last post by:
Hi,
I have an asp.net application which can be configured via web.config. I
had to setup multiple versions for multiple customers, so I made copies
of the application folder and created virtual...
|
by: Adam Nielsen |
last post by:
Hi everyone,
I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance...
|
by: william.w.oneill |
last post by:
I have an application that takes a few command line parameters. As
recommended by others in this group, I'm using a named mutex to ensure
that only one instance of the application is running. My...
|
by: Tim Arnold |
last post by:
Hi,
I'm writing a command-line interface using optparse. The cli takes
several options with a single action and several parameters to be used
in the resulting worker classes.
I've been passing...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
|
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...
| | |