Calling a Customer Timer

Hi All.

Little question here.

Running Xojo on Mac Catalina version 2019 R 3.1

I have an app that I am using to keep track of how long I spend with each customer I am working with (long story…) and it is going well save for one small issue.

I have a timer running when I click a button and start working with a customer. The timer will run until I finish, and click my end button.
Works fine… except… when the window loses focus (I switch to another program, for example) it stops counting.

Reading the forum I created a Custom Timer, which seems to work, but I can’t for the life of me figure out how to call that timer when I click start.
I’ve tried every version of the Call items I find under Timer in the language reference, but fail.

It could be my issue (misunderstanding something) but can someone tell me how to do this?


why not use 2
= DateTime.Now and use date2-date1 return a DateInterval
or you can subtract each date
= date2.SecondsFrom1970 - date1.SecondsFrom1970

  1. Add a Property of Type Date (DateTime since Xojo 2020 R1) to the Window
  2. Set the Sart Time (Property) with a click on your Start Button
  3. Keep Track of how long you are working with your customer by using a Timer, only to update a visual representation of the Time spent with the customer (by calculating the Time between Start and Now).

BTW: A Timer is not good and not meant for measuring the time. :slight_smile:

BTW2: Calculating Time differencies can be difficult using the old Date Object. But to keep things simple, i think it would be ok to just use the TotalSeconds Property of the Date Object for your Time Span Calculations.

Taken from:
Timer code runs in the main thread, the same as all other non-Thread code. This means a Timer cannot run if other code in the main thread is running. If you have a long-running process in the main thread, it could prevent your Timer from running at the intervals specified.

Here is an Example Project: (Nothing special, but i had a few moments…)