I'm not exactly sure what the problem is but your code seems to work fine on tryws: http://try.websharper.com/snippet/00007n. Do you see any errors in the console?

By on 4/8/2016 6:02 AM ()

Could it be a problem in CloudSharper? I added the example to the default SinglePageApplication, like this:

namespace SinglePageApplication

open WebSharper

<JavaScript> module Client =

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open WebSharper.JavaScript
open WebSharper.Html.Client

async {
    let x = ref 0
    while true do
        let y = !x
        JS.Alert(y.ToString())
        x := !x + 1
        do! Async.Sleep 5000
} |> Async.Start    

let content =
    Button [Text "Click me!"]
    |>! OnClick (fun _ _ ->
        JS.Alert "Clicked!")

let Main =
    Console.Log("Running JavaScript Entry Point..")
    content.AppendTo "my-container"

When I click the button, I get an Alert, but I never see any Alerts from the async loop. I verified that it works fine in try.websharper.

By on 4/8/2016 9:06 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper