Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F#Winforms Dispatcher在运行时开始出现唤醒委托问题_Winforms_F#_Delegates_Invoke_Dispatcher - Fatal编程技术网

F#Winforms Dispatcher在运行时开始出现唤醒委托问题

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

我试图创建一些C代码的F#实现,它使用Dispatcher.BeginInvoke从不同的线程操作UI。然而,我正在努力让代码正常工作

我尝试了一些不同的实现,但在调用ToggleVisibility函数时,我似乎总是得到一个“附加信息:运行时实现的委托方法的非法定义”

我们将非常感谢您的任何意见。代码如下:-

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
进入