Re: Timer issue?

Tim Jones <[email protected]> Wed, 1 Aug 2018 11:45:15 -0700
Newsgroups gmane.comp.lang.realbasic.user
Message-ID <[email protected]>
HI Jean-Luc,

I'd recommend that you use 2 timers with what you're doing.  One to handle the UI updates and the second for your thread manager.

--
Tim


> On Aug 1, 2018, at 5:20 AM, Jean-Luc Arnaud <jean-luc-E/[email protected]> wrote:
> 
> Thanks for the idea, Giulio.
> 
> Actually, the same timer is used in refreshing the UI interface. But I will try what you're suggesting and let you know.
> Jean-Luc Arnaud
> 
> Le 01/08/2018 à 14:06, giulio-yFZTWCmGK/pWk0Htik3J/[email protected] <mailto:giulio-yFZTWCmGK/pWk0Htik3J/[email protected]> a écrit :
>> Hi Jean-Luc,
>> 
>> did you try to set the timer period to a considerably longer interval?
>> 
>> just to understand if in the 10 milliseconds (that’s really a short interval maybe also for a computer), the timer event is fired again before completing its tasks, including set itself to off…
>> 
>> you could try maybe a quarter of second, that anyway is nothing if you are handling a series of files sequentially
>> 
>> just a guess,
>> 
>>  Giulio
>> 
>> Giulio Mastrosanti
>> BitBazar srl
>> 06 39737052 / 06 39725787
>> Il 1 ago 2018, 12:43 +0200, Jean-Luc Arnaud <jean-luc-E/[email protected]> <mailto:jean-luc-E/[email protected]>, ha scritto:
>>> Hi all,
>>> 
>>> I'm using a timer in order to terminate a thread treatment:
>>> 
>>> - When finished, the thread sets a flag to True and terminates (verified),
>>> 
>>> - In the Timer (with a period of 10), when the flag is on, the timer
>>> sets itself to off and then calls a method selecting the next file to be
>>> treated.
>>> 
>>> Globally, this works but sometimes, I'm getting a "File already opened"
>>> error that I send when this method tries to open the same file that is
>>> already opened. This should never happen !!! It's like the method is
>>> called again whereas it has already opened a new file and tries to
>>> reopen it ! I have verified that this is always a new file, never the
>>> last treated file.
>>> 
>>> Here is what I'm getting raising a Runtime error when this happens:
>>> 
>>> RuntimeRaiseException
>>> MainWindow.MainWindow.Next_File%%o<MainWindow.MainWindow>
>>> MainWindow.MainWindow.Refresh_Timer_Action%%o<MainWindow.MainWindow>o<Timer>
>>> XojoFramework$13892
>>> __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
>>> __CFRunLoopDoTimer
>>> __CFRunLoopDoTimers
>>> __CFRunLoopRun
>>> CFRunLoopRunSpecific
>>> RunCurrentEventLoopInMode
>>> ReceiveNextEventCommon
>>> _BlockUntilNextEventMatchingListInModeWithFilter
>>> _DPSNextEvent
>>> -[NSApplication(NSEvent)
>>> _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
>>> XojoFramework$4483
>>> XojoFramework$4484
>>> Application._CallFunctionWithExceptionHandling%%o<Application>p
>>> _Z33CallFunctionWithExceptionHandlingPFvvE
>>> XojoFramework$4483
>>> -[NSApplication run]
>>> RuntimeRun
>>> REALbasic._RuntimeRun
>>> _Main
>>> main
>>> 
>>> Can you help me understand what's happening ?
>>> 
>>> TIA
>>> 
>>> --
>>> Jean-Luc Arnaud
>>> 
>