2016-08-08 11 views
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())) 

答えて

3

解決済み!どのようにイライラは

type ToggleVisibiltyDelegate = delegate of unit -> unit 

type ToggleVisibiltyDelegate() = delegate of unit -> unit 

を回し、私がしなければならなかったすべては2つの括弧を削除した際に、様々な方法を試しので、多くの時間を費やしていると

関連する問題