首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

关于C#转为VB.net代码如下解决思路

2012-06-06 
关于C#转为VB.net代码如下C# codeprivate Timer Timer{get{if (_timer null){_timer new Timer(new T

关于C#转为VB.net代码如下

C# code
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;            }        }


[解决办法]
http://www.developerfusion.com/tools/convert/csharp-to-vb/
[解决办法]
你这个TimerCallback定义没有给出,转换肯定不成功了,因为它是用户自己定义的函数啊!
[解决办法]
new TimerCallback(delegate(object obj) 是匿名函數
要2008 2010 才支持吧。不大清楚。
[解决办法]
参考:http://www.cnblogs.com/xiaomi7732/archive/2008/06/22/1227565.html
[解决办法]
很多变量和结构都没给啊。。。。
VB.NET code
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
[解决办法]
谢谢分享

热点排行