以下代码为测试自定义类中RaiseEvent,测试结果发现RaiseEvent不起作用。不知为何?请大神指教!
PublicClassFrmTest
DimmTextAsNewTimerState
FriendWithEventsmyUpdatetimeAsTimerState
FriendWithEventsmyFinishedAsTimerState
PrivateSubFrmTest_Load(senderAsSystem.Object,eAsSystem.EventArgs)HandlesMyBase.Load
Button1.Text="Start"
EndSub
PrivateSubButton1_Click(senderAsSystem.Object,eAsSystem.EventArgs)HandlesButton1.Click
mText.StartCountdown(10.0,0.1)
EndSub
PrivateSubmyUpdatetime_UpdateTime(CountdownAsDouble)HandlesmyUpdatetime.UpdateTime
TextBox1.Text=Format(Countdown,"##0.0")
'UseDoEventstoallowthedisplaytorefresh.
My.Application.DoEvents()
EndSub
PrivateSubmyFinished_Finished()HandlesmyFinished.Finished
MsgBox("mainfin")
TextBox1.Text="Done"
EndSub
EndClass
PublicClassTimerState
PublicEventUpdateTime(ByValCountdownAsDouble)
PublicEventFinished()
PublicSubStartCountdown(ByValDurationAsDouble,ByValIncrementAsDouble)
DimStartAsDouble=DateAndTime.Timer
DimElapsedTimeAsDouble=0
DimSoFarAsDouble=0
DoWhileElapsedTimeSoFar+IncrementThen
SoFar+=Increment
RaiseEventUpdateTime(Duration-SoFar)
EndIf
ElapsedTime=DateAndTime.Timer-Start
Loop
MsgBox("fin")
RaiseEventFinished()
EndSub
EndClass
分 -->
|