I think you will like the F # solution :-).
To simplify the example, I save the price and timestamps in a list containing tuples (the first element is the delay from the last update, and the second element is the price). It should not be too difficult to convert your input into this format. For instance:
let prices = [ (0, 10.0); (1000, 10.5); (500, 9.5); (2500, 8.5) ]
, . , :
let evt = new Event<float>()
evt.Publish.Add(printfn "Price updated: %f")
- - , , , :
async { for delay, price in prices do
do! Async.Sleep(delay)
evt.Trigger(price) }
|> Async.StartImmediate
StartImmediate, , ( , ). (, ).
EDIT. - , , :
type ReplyDataStream(prices) =
let evt = new Event<float>()
member x.Reply() =
member x.PriceChanged =
evt.Publish
, , stream.PriceChanged.Add(...), Reply()