4
Dispatcher.BeginInvokeを使用して別のスレッドからUIを操作するC#コードのF#実装を作成しようとしました。しかし、私はコードを動作させるのに苦労しています。F#Winforms Dispatcher BeginInvokeランタイムにデリゲートの問題
私はいくつかの異なる実装を試みましたが、私はいつも "追加情報:実行時に実装されたデリゲートメソッドの不正な定義"を取得するようです。 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()))