我已经编写了一些代码,在我的方法参数中执行一个操作:
_myService.MyMethod(userId, profileId, Sub(message As EventArgs) _eventAggregator.SendMessage(message))
这是被调用的方法:
Public Sub MyMethod(userId As Guid, profileId As Guid, ByVal action As Action(Of EventArgs))
Dim proxy = BuildProxy()
AddHandler proxy.MyMethodCompleted, Sub(o, e) action(e)
Using New OperationContextScope(proxy.InnerChannel)
Dim request = New MyMethodRequest() With {.gebruikerId = userId, .omgevingsId = omgevingId}
proxy.MyMethodAsync(request)
End Using
End Sub
现在我想扩展传递给我的服务方法的 Sub 以包括:
_myService.MyMethod(userId, profileId, Sub(message As EventArgs) _eventAggregator.SendMessage(message)
_localVariable = e.Result
End Sub)
这显然是行不通的。这可能吗?