I wrote the following F# code to implement a countdown timer:

    let mutable counter    = 120
    let mutable timerText  = ""

    do 
        let timer = new Timer()
        timer.AutoReset <- true
        timer.Interval  
                            if counter = 0 then
                                timer.Stop()
                            else
                                counter     <- counter - 1
                                x.TimerText <- TimeSpan(0,0,counter).ToString("m\:ss")
                         )
        timer.Start()

Here's the UI that reflects the countdown timer:

Timer

Advertisements