I am using this delegate to invoke my methode:
Private 开发者_开发知识库Delegate Sub NoArgDelegate()
Dim dl As New NoArgDelegate(AddressOf MyLoad)
Me.Dispatcher.BeginInvoke(dl, Windows.Threading.DispatcherPriority.ContextIdle)
Private Sub MyLoad()
End Sub
Is there any way to do this without my NoArgDelegate?
Thanks
Since you're using WPF, the Action
delegate should be available. So you don't need to define your own delegate.
Well you could use MethodInvoker
or Action
instead of creating your own delegate :) However, I assume that what you're really asking about is the need to explicitly specify the delegate type when you call BeginInvoke
.
The problem is that Dispatcher.BeingInvoke
takes any delegate, so the compiler won't know what to convert AddressOf MyLoad
to.
You could add your own extension method though which has a parameter of Action
- I believe that would let you call it without explicitly specifying the delegate in the calling code.
精彩评论