[Gambas-user] Forward events from constructor

Tobias Boege taboege at ...626...
Sun Oct 4 19:22:12 CEST 2015


On Sun, 04 Oct 2015, Beno??t Minisini wrote:
> >> It's not technically necessary to do that, but it avoids a lot of
> >> possible annoying bugs in your code.
> >>
> >
> > I understand. And by the way, that Timer trick works even in the following
> > form:
> >
> > --8<--[ ValidateBox.class]--------------------------------------------------
> >    Private $frmControl As FValidateBox
> >    Private $hTimer As Timer
> >
> >    Public Sub _new()
> >      $frmControl = New FValidateBox(Me) As "Control"
> >
> >      $hTimer = New Timer As "FirstCheck"
> >      $hTimer.Delay = 1
> >      $hTimer.Start()
> >    End
> >
> >    Public Sub FirstCheck_Timer()
> >      $hTimer.Stop()
> >      $frmControl.txtInput_Change() ' Trigger first validation
> >    End
> > --8<------------------------------------------------------------------------
> >
> > The 1 millisecond timer delay is provocative enough that everyone who reads
> > the code will get that this is a hack and why it's there for. It is not as
> > self-explanatory as the GB.Post() API which we have in C, though.
> >
> 
> You should not do that (put an arbitrary delay), but instead use the 
> Timer.Trigger() method, which will raise the Timer event at the next 
> event loop.
> 

Oh, thanks!

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list