470,874 Members | 1,509 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

Compile error on TimerCallback

I am getting a compile error ("No overload for 'Timer_Tick' matches delegate
'System.Threading.TimerCallback'") on the following code and can't figure
out why. Does anyone have any ideas?

public partial class CrystalService : ServiceBase
{
public CrystalService()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
TimerCallback tcb = new TimerCallback(this.Timer_Tick);
Timer timer = new Timer(tcb);
}

protected override void OnStop()
{
}

public void Timer_Tick()
{
}
}
Apr 28 '06 #1
1 4083
"Thirsty Traveler" <nf*@nospam.com> wrote:
I am getting a compile error ("No overload for 'Timer_Tick' matches delegate
'System.Threading.TimerCallback'") on the following code and can't figure
out why. Does anyone have any ideas? TimerCallback tcb = new TimerCallback(this.Timer_Tick); public void Timer_Tick()


Timer_Tick must match the declaration for the TimerCallback delegate:

public delegate void TimerCallback(Object state)

That means you must modify your Timer_Tick method to receive an object
parameter:

public void Timer_Tick(object state)

-- Barry
Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Carmine Cairo | last post: by
10 posts views Thread by Chris LaJoie | last post: by
2 posts views Thread by T. | last post: by
reply views Thread by jones6 | last post: by
6 posts views Thread by Thomas Connolly | last post: by
2 posts views Thread by BruceWho | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.