I tried to create an F # implementation of some C # code that uses Dispatcher.BeginInvoke to control the user interface from another thread. However, I am struggling to get the code to work.
I tried several different implementations, but I always get "Additional information: Invalid definition for executable delegation method". exception when calling the ToggleVisibility function.
Any input would be greatly appreciated. Here is the code: -
open System
open System.Drawing
open System.Windows.Forms
type ToggleVisibiltyDelegate() = delegate of unit -> unit
type NotifyWindow() as form =
inherit Form()
let label1 = new Label()
do form.InitializeForm
member this.ToggleVisibility () =
if (this.Visible) then
this.BeginInvoke(new ToggleVisibiltyDelegate(fun () -> this.Hide()))
else
this.BeginInvoke(new ToggleVisibiltyDelegate(fun () -> this.Show()))
Mattp source
share