open system open system.windows open fsharp.charting open fsharp.charting.charttypes [<stathread>] let win = window(title="chart") let data = [|for i=1 10 yield (i, i*i)|] let e = event<_>() let ev = e.publish let chart = livechart.line (ev) |> chartcontrol let host = new forms.integration.windowsformshost(child=chart) win.content <- host e.trigger data // throws error here application().run(win) |> ignore
i trying figure out how f# charting's livecharts work, of examples use timers or other complicated stuff. above simplest make it, reason keep getting object reference not set instance of object.
exception when trigger event.
any idea why happening?
edit: here trace. had remove catch in above example dump.
unhandled exception: system.nullreferenceexception: object reference not set instance of object. @ fsharp.charting.notifyseq.iobservable-1-observeon@225-1.system-iobserver`1-onnext(t value) in c:\github\fsharp.charting\src\fsharp.charting.fs:line 226 @ <startupcode$fsharp-core>.$event.h@174-1.invoke(object sender, t args) @ microsoft.fsharp.control.fsharpevent`1.trigger(t arg) @ <startupcode$charts>.$program.main@() in c:\users\marko\documents\visual studio 2015\projects\poker experiments\charts\program.fs:line 20
looking @ fscharting source code, seems there no active synchronization context @ time of subscribing.
you should create chart on window initialization, happen after application.run
, creates wpf synchronization context.
Comments
Post a Comment