4
I have a class (in VB) that returns an event of TimeOut
, that is, if time runs out it returns an event content with a string with the data I need using Raiseevent. How can I treat this event in the main class that is in C#. I tried using delegate but could not. Thanks.
Code:
Public Class Dados
Public Event _TrateTimeOut(ByVal dados As Dados)
Private Sub MonitoraTimeOut()
If TimeOut Is Nothing Then
TimeOut = New Timers.Timer
TimeOut.Interval = 10000
AddHandler TimeOut.Elapsed, AddressOf TrateTimeOut
TimeOut.Start()
Else
TimeOut.Stop()
TimeOut.Start()
End If
End Sub
Private Sub TrateTimeOut()
RaiseEvent _TrateTimeOut(Me)
End Sub
End Class
You can ask your question an excerpt of code explaining how this solution works?
– Leonel Sanches da Silva
Code added!!
– JcSaint
From what I understand,
_TrateTimeOut()
is declared somewhere. Where?– Leonel Sanches da Silva
At the beginning of the Data class with: Public Event _Tratetimeout(Byval Data)
– JcSaint
You can add it to the question too, please?
– Leonel Sanches da Silva
Added, you have an idea how I can do ?! :)
– JcSaint
Well, the C# class needs to have an event with the following prototype:
private void FuncaoQueTrataOEvento(object sender, EventArgs e)
, and at startup you need to instantiateDados
and pass the function inside the classDados
. I’ll try an answer.– Leonel Sanches da Silva
I tried that, but the Monitor() is not started.
– JcSaint