translate C# from VB.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some problem in translate the last row of this class this class

Public Delegate Sub UIUpdate(ByVal args() As Object
Public Class Invoke

Private _control As Contro
Private _uiUpdate As UIUpdat
Private _args() As Objec

Public Sub New(ByVal c As Control
' store the control that is to run the method on its threa
_control =
End Su

Public Sub Invoke(ByVal UIDelegate As UIUpdate,
ByVal ParamArray args() As Object
' called by the client and passed the delgate that
' points to the method to ru
' as well as the argument
_args = arg
_uiUpdate = UIDelegat
_control.Invoke(New EventHandler(AddressOf _invoke)
End Su

Private Sub _invoke(ByVal sender As Object, ByVal e As EventArgs
' this is now running on the same thread as the contro
' so freely call the delegat
_uiUpdate.Invoke(_args) // <== THIS LINE IS MY PROBLEMS ================
End Su

End Clas

Can someone can help me please?

Thanks
 
How did you declare Public Sub Invoke(ByVal UIDelegate As UIUpdate, ByVal
ParamArray args() As Object) in C#?
It should be:
public Invoke(UIUpdate UIDelegate, params object[] args)
 
I dont understand your answer.

I have a Error: "Invoke cannot be called directly on a delegate." on the
last row.

This class will be use to update the UI of a form in the Compact Framework
and pass it arguments.


Alex Feinman said:
How did you declare Public Sub Invoke(ByVal UIDelegate As UIUpdate, ByVal
ParamArray args() As Object) in C#?
It should be:
public Invoke(UIUpdate UIDelegate, params object[] args)


newMan said:
I have some problem in translate the last row of this class this class:

Public Delegate Sub UIUpdate(ByVal args() As Object)
Public Class Invoker

Private _control As Control
Private _uiUpdate As UIUpdate
Private _args() As Object

Public Sub New(ByVal c As Control)
' store the control that is to run the method on its thread
_control = c
End Sub

Public Sub Invoke(ByVal UIDelegate As UIUpdate, _
ByVal ParamArray args() As Object)
' called by the client and passed the delgate that
' points to the method to run
' as well as the arguments
_args = args
_uiUpdate = UIDelegate
_control.Invoke(New EventHandler(AddressOf _invoke))
End Sub

Private Sub _invoke(ByVal sender As Object, ByVal e As EventArgs)
' this is now running on the same thread as the control
' so freely call the delegate
_uiUpdate.Invoke(_args) // <== THIS LINE IS MY PROBLEMS =================
End Sub

End Class


Can someone can help me please?!

Thanks
 
Alex is saying that you can't. You can only call Invoke on methods that
exacly follow the EventHandler method signature. "Passing" data has to be
done using a global variable.

-Chris

Franky said:
I dont understand your answer.

I have a Error: "Invoke cannot be called directly on a delegate." on the
last row.

This class will be use to update the UI of a form in the Compact Framework
and pass it arguments.


Alex Feinman said:
How did you declare Public Sub Invoke(ByVal UIDelegate As UIUpdate, ByVal
ParamArray args() As Object) in C#?
It should be:
public Invoke(UIUpdate UIDelegate, params object[] args)


newMan said:
I have some problem in translate the last row of this class this class:

Public Delegate Sub UIUpdate(ByVal args() As Object)
Public Class Invoker

Private _control As Control
Private _uiUpdate As UIUpdate
Private _args() As Object

Public Sub New(ByVal c As Control)
' store the control that is to run the method on its thread
_control = c
End Sub

Public Sub Invoke(ByVal UIDelegate As UIUpdate, _
ByVal ParamArray args() As Object)
' called by the client and passed the delgate that
' points to the method to run
' as well as the arguments
_args = args
_uiUpdate = UIDelegate
_control.Invoke(New EventHandler(AddressOf _invoke))
End Sub

Private Sub _invoke(ByVal sender As Object, ByVal e As EventArgs)
' this is now running on the same thread as the control
' so freely call the delegate
_uiUpdate.Invoke(_args) // <== THIS LINE IS MY PROBLEMS =================
End Sub

End Class


Can someone can help me please?!

Thanks
 
Hi Franky,

Check out this FAQ item:

7.10. Can I create a custom delegate to pass to invoke?
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#7.10


--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
Franky said:
I dont understand your answer.

I have a Error: "Invoke cannot be called directly on a delegate." on the
last row.

This class will be use to update the UI of a form in the Compact Framework
and pass it arguments.


Alex Feinman said:
How did you declare Public Sub Invoke(ByVal UIDelegate As UIUpdate, ByVal
ParamArray args() As Object) in C#?
It should be:
public Invoke(UIUpdate UIDelegate, params object[] args)


newMan said:
I have some problem in translate the last row of this class this class:

Public Delegate Sub UIUpdate(ByVal args() As Object)
Public Class Invoker

Private _control As Control
Private _uiUpdate As UIUpdate
Private _args() As Object

Public Sub New(ByVal c As Control)
' store the control that is to run the method on its thread
_control = c
End Sub

Public Sub Invoke(ByVal UIDelegate As UIUpdate, _
ByVal ParamArray args() As Object)
' called by the client and passed the delgate that
' points to the method to run
' as well as the arguments
_args = args
_uiUpdate = UIDelegate
_control.Invoke(New EventHandler(AddressOf _invoke))
End Sub

Private Sub _invoke(ByVal sender As Object, ByVal e As EventArgs)
' this is now running on the same thread as the control
' so freely call the delegate
_uiUpdate.Invoke(_args) // <== THIS LINE IS MY PROBLEMS =================
End Sub

End Class


Can someone can help me please?!

Thanks
 
Back
Top