[英]Converting AddressOf from VB6 to c#
In VB6 we have the below code. 在VB6中,我们有以下代码。
g_CTimer.TimerID = SetTimer(0&, 0&, g_CTimer.Interval, AddressOf TimerProc)
The TimerProc method is as below TimerProc方法如下
Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
On Error Resume Next
If g_CTimer Is Nothing Then Exit Sub
g_CTimer.ThatTime
End Sub
How do we convert that call "AddressOf TimerProc" in C#. 我们如何在C#中转换该调用“ AddressOf TimerProc”。
Thanks in Advance. 提前致谢。
Regards Achyuth 关于阿基乌斯
In C# you can just omit the AddressOf
keyword. 在C#中,您可以省略AddressOf
关键字。 In VB.NET it explicitly implies that you are sending the method pointer as an argument (a pointer to TimerProc
, in this case). 在VB.NET中,它明确暗示您将方法指针作为参数发送(在本例中为TimerProc
的指针)。 In C# you can just use the method name directly. 在C#中,您可以直接使用方法名称。
That said, you're probably better off just re-implementing this with a normal timer ( Windows.Forms.Timer
or some other). 就是说,您最好还是用一个普通的计时器( Windows.Forms.Timer
或其他计时器)重新实现它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.