-
Notifications
You must be signed in to change notification settings - Fork 0
/
Runners.fs
28 lines (25 loc) · 982 Bytes
/
Runners.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
namespace fsharpTopShelf
module Runners =
open System
open System.Timers
open Topshelf
type TimerOutput(timer : Timer) =
new () =
let timer = new Timer()
timer.Interval <- 1000.0
timer.AutoReset <- true
timer.Elapsed.Add(fun args ->
let timeNow = DateTime.Now.ToString()
printfn "It is %s and all is well" timeNow)
TimerOutput(timer)
member this.Start =
printfn "Start"
timer.Start()
member this.Stop =
printfn "Stop"
timer.Stop()
type Interop =
static member init(svc : ServiceConfigurators.ServiceConfigurator<TimerOutput>) =
svc.ConstructUsing(fun (name: string) -> new TimerOutput()) |> ignore
svc.WhenStarted(fun (tc : TimerOutput) -> tc.Start) |> ignore
svc.WhenStopped(fun (tc : TimerOutput) -> tc.Stop) |> ignore