3
I have the following method/function and need to call the method/function criaTimerTendencia
that is within the class TagAnalogicaAtiva
.
private static void VerificaEnvioDeMensagensSignalR(object sender, EventArgs e)
{
if (ExisteTendenciaParaTag)
{
TagAnalogicaAtiva.criaTimerTendencia();//preciso chamar este metodo/função
}
}
Below is the code of the method criaTimerTendencia()
class TagAnalogicaAtiva : TagAtiva
{
public void criaTimerTendencia()
{
var tendencia = Processamento.PegaTendencia(IdTag);
timer = new System.Timers.Timer(tendencia.TempoDeColeta);
timer.Elapsed += insereTendenciaDB;
timer.AutoReset = true;
timer.Enabled = true;
}
}
Only the following error is happening:
An Object Reference is required for the non-static field, method, or Property 'Taganalogicaativa.criaTimerTendencia()'
How do I solve this problem?
what kind of
sender
? tries to make avar tipo = sender.GetType()
to see the guy thesender
.– Tobias Mesquita
try this
TagAnalogicaAtiva tag = new TagAnalogicaAtiva ();
tag.criaTimerTendencia();
Or changes ;public static void criaTimerTendencia()
– Jhonatan Jorge de Lima
Where the variable is declared
timer
? You can place more parts of this class, especially the use oftimer
?– Maniero
why you have not created a Taganalogicaativa obj in the static class and accessed it ??
– Guilherme Golfetto