F#: Implementing a Countdown Timer

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: