Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a method with one arguement (at the service application & on statrt(string[] args method)
then i want to call a method (timer method (private void timer1_Tick(object sender, EventArgs e)
via this (start method)

i call this solution

C#
protected override void OnStart(string[] args )
       {
           timer1_Tick(this , e);
       }


but when i call one error occurs:

the name 'e' does not exist in the current context

any have a solution?
Posted

Hello,

the Timer requires an EventArgs called 'e'.
You dont have an objekt with the name 'e'.

You can call the Method like this:

timer1_Tick(this, EventArgs.Empty);
 
Share this answer
 
Yes, don't try to pass something that does not exist. If you can't work out that the error is correct, then I am at a loss what it is you think you're doing with a compiler.

EventArgs.Empty is what you'd use if you need event args and don't have any, as is clearly the case here. A real programmer would factor out the method that does something, and call it in your timer tick, rather than call a timer tick to do something, but that's another story.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900