创建自定义 Windows 服务计时器:主要是将名称添加到计时器
Create Custom Windows Service Timer : Basically Add Name to Timer
我有一个传递定时器的函数,例如
Private Sub Process(myTimer as timer)
Select Case myTimer.ToString()
Case "Timer1"
Case "Timer2"
Case "Timer3"
End Select
End Sub
但是,当我传递一个特定的定时器时——我无法在 Process() 中找到
当前正在处理哪个定时器。
计时器具有属性,
如何获取计时器的名称?
自定义计时器怎么样? - 如何在创建 CustomTimer 时将定时器设置为 MyTimer?
Public Class CustomTimer
Inherits Timer
Public Property TimerName As String
Public Sub New(t As Timer)
End Sub
End Class
似乎通过名称(字符串)枚举或识别 .net 对象越来越流行,尤其是在 Visual Basic 社区中。
在我看来这是错误的,.NET API 建议对框架没有的所有程序员使用 Tag
Timer t1;
Timer t2;
...
t1.Tag = new MyAdditionalInfo("foo");
t2.Tag = new MyAdditionaInfo("bar");
.. or simply
t1.Tag = "foo";
t2.Tag = "bar";
我有一个传递定时器的函数,例如
Private Sub Process(myTimer as timer)
Select Case myTimer.ToString()
Case "Timer1"
Case "Timer2"
Case "Timer3"
End Select
End Sub
但是,当我传递一个特定的定时器时——我无法在 Process() 中找到 当前正在处理哪个定时器。
计时器具有属性,
如何获取计时器的名称?
自定义计时器怎么样? - 如何在创建 CustomTimer 时将定时器设置为 MyTimer?
Public Class CustomTimer
Inherits Timer
Public Property TimerName As String
Public Sub New(t As Timer)
End Sub
End Class
似乎通过名称(字符串)枚举或识别 .net 对象越来越流行,尤其是在 Visual Basic 社区中。 在我看来这是错误的,.NET API 建议对框架没有的所有程序员使用 Tag
Timer t1;
Timer t2;
...
t1.Tag = new MyAdditionalInfo("foo");
t2.Tag = new MyAdditionaInfo("bar");
.. or simply
t1.Tag = "foo";
t2.Tag = "bar";