0

在 VB6 中,我们有以下代码。

g_CTimer.TimerID = SetTimer(0&, 0&, g_CTimer.Interval, AddressOf TimerProc)

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

我们如何在 C# 中转换该调用“AddressOf TimerProc”。

提前致谢。

问候阿秋斯

4

1 回答 1

1

In C# you can just omit the AddressOf keyword. In VB.NET it explicitly implies that you are sending the method pointer as an argument (a pointer to TimerProc, in this case). In C# you can just use the method name directly.

That said, you're probably better off just re-implementing this with a normal timer (Windows.Forms.Timer or some other).

于 2013-07-30T12:24:17.447 回答