关于C#转为VB.net代码如下
private Timer Timer { get { if (_timer == null) { _timer = new Timer( new TimerCallback(delegate(object obj) { TimeSpan ts = DateTime.Now - _lastReceiveTime; if (ts.TotalMilliseconds > ReceiveTimeout) { _lastReceiveTime = DateTime.Now; OnReceiveFileTimeout(EventArgs.Empty); } }), null, Timeout.Infinite, _interval); } return _timer; } }
Dim _timer As System.Threading.Timer Private _lastReceiveTime As DateTime = Now Private ReceiveTimeout As Integer = 1000 Private Private Sub obj() Dim ts As TimeSpan = Now - _lastReceiveTime If (ts.TotalMilliseconds > ReceiveTimeout) Then _lastReceiveTime = Now OnReceiveFileTimeout(EventArgs.Empty) End If End Sub Private Sub OnReceiveFileTimeout(ByVal eventArgs As EventArgs) End Sub Private ReadOnly Property GetTimer() Get If _timer Is Nothing Then _timer = New System.Threading.Timer(New System.Threading.TimerCallback(AddressOf obj), Nothing, Timeout.Infinite, _interval) End If Return _timer End Get End Property
[解决办法]
谢谢分享