Invoke Event

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

Hello,

The sample code is below

**************************************
Private sub invokeEvent()

'Here i want to invoke all the codes(A,B,C) in Timer1_Tick(), how to do?

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

A...
B...
C...

End Sub
 
* "yxq said:
The sample code is below

**************************************
Private sub invokeEvent()

'Here i want to invoke all the codes(A,B,C) in Timer1_Tick(), how to do?

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

A...
B...
C...

End Sub

Derive a class from 'Timer' and extend it as shown below:

\\\
Public Class ExtendedTimer
Inherits System.Windows.Forms.Timer

Public Sub PerformTick()
MyBase.OnTick(EventArgs.Empty)
End Sub
End Class
///

Then use this timer class instead of the 'System.Windows.Forms.Timer'.
You can raise the 'Tick' event by calling the object's 'PerformTick'
method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top