[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: How to know if application already running?

Whoops.  I went back and rechecked my code.  What I was thinking of was Display#getShells().  Ignore what I said about there being a way to do it with Display.  :-)

As to port 25, you'll have the same problem with just about any port.  I guess 25 is as good as any other.

Daniel

Benjamin Pasero wrote:
Daniel Spiewak wrote:

  
I would run it on port 25, the smtp mail server port.  This port is
fairly commonly allowed, but few systems actually run a mail server.

As to the Display class, it is a static method which to the best of my
knowledge, queries the system for all open Shell(s), even the native
ones, and returns them in an array.  I use this method to show error
dialogs when my application unexpected quits.  
    

I am not seeing any public static method in Display that returns an
array of Shells. Are you using an older
version of SWT, maybe from 3.0?

  
But, all in all, I'd use sockets first.  More reliable, more flexible,
less confusing, and all around a more elegant hack.
    

I think a Display-Method would be most elegant. The disadvantage of
Sockets is always that the user most likely
will be prompted by his firewall to allow the application to communicate
on the given port. Having port 25, most
users will rightfully ask, why the application requires the SMTP Port to
be opened.

Ben

  
Daniel

Benjamin Pasero wrote:

    
Doug Pearson wrote:

 

      
I'd thought about using files, but hadn't considered a socket
solution.    That sounds good and will work fine on any platform. 
Thanks,
   

        
Maybe if you could share your solution with Sockets here? I was thinking
of implementing a Socket-way
to get out if my application is already running. But I wonder what port
to chose to run the Socket through?

Ben

 

      
Doug

Benjamin Pasero wrote:

   

        
Daniel Spiewak wrote:


     

          
You have several options on this one, only one of them having to do
with SWT itself.  The Display class has a method which returns an
array of all the Shell(s) open on that Display.  Alternatively, you
can use file-locking, even server sockets to implement the behavior.
       

            
As far as I can see, a new Display class is created with each new SWT
application. So, how should one display
know of the Shells of another application? I dont think (and checked)
that its working.

sockets seem to be the best (and most common) way to achieve this.

Ben


     

          
Daniel

Doug Pearson wrote:


       

            
Is there any way to detect from one SWT application if another SWT
application is already running?

In Windows the usual solution to this was using ::FindWindow() to
look for the window class (or name).

Is there anything like that or any alternative available in SWT?

Doug