By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,035 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,035 IT Pros & Developers. It's quick & easy.

Open running processes

P: n/a
Hi all,

I have a programm. In this program i've made the restriction that only
one instance can run at the time. (done with mutex).
Now i'd like it to open the running (make visible) instance when
someone want's to open it a second time.
Does anybody know how to do this? I hope you all understand what i
mean. My English isn't to good...

Greetz Rudi

Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
It is a wxWindow app. It is a kind of datamanager. it is possible to
minimize it to the systray.

hmm.. i've thought of an solution using memorymapping. see if it
works.. don't know if it is the 'best' or 'safest' way.. but ok.

Greetz.

ps. I'm always willing to learn! :D

Jul 19 '05 #2

P: n/a
Well it doesnt work yet, but its gonna! ;)
i've tested it with a little app. There is my main app (called it
server) wich contains a thread. This thread listens to a mm (memory
mapping) when an other program sets a flag
(finished_producing_event.set() ) it just calls self.iconize(false)

I'm not sure what pieces of code i have to post here.. posting all of
it makes it too large i believe :)

From server:
ID_MESSAGECH = wxNewId()

def EVT_RESULT(win, func):
win.Connect(-1, -1, ID_MESSAGECH, func)

class ResultEvent(wxPyEvent):

def __init__(self):
wxPyEvent.__init__(self)
self.SetEventType(ID_MESSAGECH)

class listener(Thread):
def __init__(self, frame):
Thread.__init__(self)
self.frame = frame
self.setDaemon(1)

self.stopped = False

#shared_memory = mmap.mmap (0, common.SHARED_MEMORY_SIZE,
common.SHARED_MEMORY_NAME)
#ready_to_consume_event = events.Win32Event
(common.READY_TO_CONSUME)
#finished_producing_event = events.Win32Event
(common.FINISHED_PRODUCING)

def run(self):
while not self.stopped:
try:
finished_producing_event.wait()
wxPostEvent(self.frame,ResultEvent(None))
except Exception,e:
print "Error: " , e

def stop(self):
self.stopped = True

within the frame:
[code:1:080343f1b1]
listen = listener(self)
listen.start()

EVT_RESULT(self, self.OnChange)

def OnChange(self, event):
shared_memory.seek(0)
tekstding = shared_memory.readline()
if(tekstding.strip() ==
"maximize"):
self.Iconize(False)
self.Show(False)
elif(tekstding.strip() ==
"minimize"):
self.Iconize(True)
self.Show(True)
self.panel.tekst.SetValue(tekstding)
[/code:1:080343f1b1]

Hope you can see now how it works! Greetz

Jul 19 '05 #3

P: n/a
Well i want a external app to maximize and minimize my app.
And later on i want the external one to send some data. Thought this
would be the most easy (and fast) way!

Greetz

Jul 19 '05 #4

P: n/a
> Tim Goldenwrote:

Rudi. I, at least, am reading this via the mailing list, not
via Usenet nor via Google. This means that if you don't put
any kind of context in what you post, I have to guess at what
you're responding to. (All I see is the exact text you typed,
nothing else).

Assuming that you're answering my question: why use mmap and
not just two events? I understand what your overall plan is,
and it looks like you have a way to solve it. It just seemed
that you might be able to achieve the same thing with two
events: one for maximize and one for minimize. Why would
this be better? Well, only because it seems to me slightly simpler
than one event and a separate mmap mechanism. But I've never
done what you're doing, so I may well be completely wrong.

TJG


Hi Tim,

I'm sorry did not realize it!
U are right! (i believe) at first i put in the minimize for testing.
I'm only using the maximize.
But it seemed handy to do it this way and beeing abled to send over
data from an other programm. That's what i want to use the mmap for.
Or am i missing something. because i'm not really seeing what your
point is. Because it is a complete different process what is calling
the maximize (or minimize) i can't just create an event and call it
(or can i?)

Greetz

Jul 19 '05 #5

P: n/a
> Tim Goldenwrote:
If you wanted to send over arbitrary data from another application,
then this is certainly a way to do it. (Another way might be to use a Windows pipe, for example). My point was only that if you are signalling an event as a wake-up call plus an atom of extra information saying "max" or "min", and you weren't considering any expansion of this
vocabulary to include other commands, then two distinct events might be simpler, one signalling "maximize", the other "minimize".

Please don't take this as any criticism of your work: there's no one right design decision here; I was merely curious as to the reasons
behind yours.

TJG


Thanx for thinking with me! It really helps to have some other
opinions! It might look simpeler to make two distinct events. But
reading out the mm is really easy to do. So i didn't make more events
for maximizing and minimizing. But further on i'm gonna use it. I
think by now i have all the thing's i need to solute my problems.
Thnx

Rudi

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.