Advertisement
Guest User

Repro

a guest
Aug 7th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.51 KB | None | 0 0
  1. open System
  2. open System.Threading
  3.  
  4. let callThrice (action : Action<_>) =
  5.     for i = 0 to 2 do
  6.         action.Invoke ()
  7.         Thread.Sleep 500
  8.  
  9. let makeHandler () =
  10.     let count = ref 0
  11.     fun () -> printfn "Count: %d" !count
  12.               incr count
  13.  
  14. let try1 () =
  15.     printfn "try1"
  16.     let handler = makeHandler ()
  17.     callThrice (Action<_> handler)
  18.  
  19. let try2 () =
  20.     printfn "try2"
  21.     callThrice (Action<_> (makeHandler ()))
  22.  
  23. try1 ()
  24. try2 ()
  25. printfn "Done"
  26. Console.ReadKey true |> ignore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement