F#Winforms Dispatcher在运行时开始出现唤醒委托问题
我试图创建一些C代码的F#实现,它使用Dispatcher.BeginInvoke从不同的线程操作UI。然而,我正在努力让代码正常工作 我尝试了一些不同的实现,但在调用ToggleVisibility函数时,我似乎总是得到一个“附加信息:运行时实现的委托方法的非法定义” 我们将非常感谢您的任何意见。代码如下:-F#Winforms Dispatcher在运行时开始出现唤醒委托问题,winforms,f#,delegates,invoke,dispatcher,Winforms,F#,Delegates,Invoke,Dispatcher,我试图创建一些C代码的F#实现,它使用Dispatcher.BeginInvoke从不同的线程操作UI。然而,我正在努力让代码正常工作 我尝试了一些不同的实现,但在调用ToggleVisibility函数时,我似乎总是得到一个“附加信息:运行时实现的委托方法的非法定义” 我们将非常感谢您的任何意见。代码如下:- open System open System.Drawing open System.Windows.Forms type ToggleVisibiltyDelegate() = d
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()))
解决了!我花了这么多时间尝试各种方法,而我所要做的只是删除两个括号,然后旋转
type ToggleVisibiltyDelegate() = delegate of unit -> unit
type ToggleVisibiltyDelegate = delegate of unit -> unit
进入