[Gambas-user] Question: Wait-sign on start

Gianluigi bagonergi at gmail.com
Tue Feb 19 13:18:18 CET 2019


If you don't want to open a new instance of your project:

>From a code by Jussi Lahtinen:
'-----------------------------------------------
Public Sub Form_Open()

  Dim sOutput As String
  Dim s As String = Application.Name

  Exec ["pgrep", "-f", "-l", s] Wait To sOutput

  If Split(Trim$(sOutput), gb.NewLine).Count > 1 Then
    Me.Close
  Endif

End
'-------------------------------------------------------

Another solution from this discussion on the Gambas-it forum [0]:

'----------------------------------------------------------------------
' The gb.settings component must be activated
Private hSetting As Settings

Public Sub Form_Open()

  Dim iPid As Integer = Application.Id
  Dim sPid, sSysPid As String

  hSetting = New Settings(User.Home &/ "myapp.conf")
  If (hSetting["Application/pid", 0] = 0) Then
    ' this is the first execution
    hSetting["Application/pid"] = iPid
    hSetting.Save
  Else
    sPid = hSetting["Application/pid"]
    Shell "ps aux | grep " & sPid & "  | grep -wv grep | wc -l" Wait To
sSysPid
    sSysPid = Replace(sSysPid, "\n", "")
    If (Val(sSysPid) > 0) Then
      Me.Close ' Application already active
    Else
      ' previous instance that probably has an abortion
      hSetting["Application/pid"] = iPid
      hSetting.Save
    Endif
  Endif

End
'------------------------------------------------------------
Regards
Gianluigi

[0] http://www.gambas-it.org/smf/index.php?topic=2056.0

Il giorno mar 19 feb 2019 alle ore 10:10 Rolf-Werner Eilert <
rwe-sse at osnanet.de> ha scritto:

> Thank you Fabien,
>
> good idea, but it doesn't help here. It is the time from clicking the
> icon to starting the program which gets no indicator.
>
> Strangely, Mate seems to know that starting a binary needs some
> indication to the user like "This icon was clicked".
>
> When there is a Gambas app behind, it seems not to know. So there is no
> reaction when double-clicking the icon, and the user wonders "has my
> double-click been accepted, or is Mate still waiting for something?"
>
> Then, mostly, the program pops up and confirms that the double-click was
> seen. But prior to this, there is no loading indicator.
>
> I just found, the Gambas IDE itself doesn't have a starting indicator.
>
> Regards
> Rolf
>
>
> Am 13.02.19 um 05:24 schrieb Fabien Bodard:
> > Hi,
> >
> > At the start of your program do
> >
> > Inc application.Busy
> >
> >
> > Then when your application is loaded
> > For exemple at the end of form.open or form.show of your main form just
> do
> >
> > Dec Application.Busy
> >
> > When Application.Busy is >to 0 then then the wait cursor is displayed.
> >
> > This way allow to have imbricated call to the waiting state
> >
> > Regards,
> >
> > Fabien Bodard
> >
> > Le mar. 12 févr. 2019 18:37, Rolf-Werner Eilert <rwe-sse at osnanet.de
> > <mailto:rwe-sse at osnanet.de>> a écrit :
> >
> >     Under Ubuntu Mate I don't get a Wait mouse icon when I start a Gambas
> >     program. Sometimes I am too hasty and don't doubleclick at one spot,
> so
> >     it doesn't start the program. But sometimes it just starts a bit more
> >     slowly, so when I'm nervous I start it twice. You know what I
> mean... :)
> >
> >     Is it possible to get a Wait mouse icon on start, or is it a
> >     drawback of
> >     the interpreter which can't be changed?
> >
> >     I know KDE has an option to set a jumping mouse on any doubleclick of
> >     some icon on the desktop, but in Mate other programs (those which are
> >     binaries) have it too.
> >
> >     Regards
> >     Rolf
> >
> >     ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> ]----
> >
> >
> >
> > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> >
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190219/5dd00428/attachment.html>


More information about the User mailing list