Cannot get the Timer to work in the current context. I copied an example and changed the timer callback to my method and get Error 1 “No overload for ‘UpdateTime’ matches delegate ‘System.Threading.TimerCallback’”. I am sure that the error is on me but I just don’t understand the language enough to know what it is talking about. Any help?
public static void Main()
{
const Int32 c_port = 80; // Port used for http requests
byte[] ip = { 192, 168, 0, 150 }; // Assigned IP address
byte[] subnet = { 255, 255, 255, 0 }; // Assigned Subnet
byte[] gateway = { 192, 168, 0, 1 }; // Assigned Gateway Address
byte[] mac = { 0x00, 0x9A, 0xD2, 0xC2, 0xD9, 0x2A }; //Randomly generated MAC from http://www.macvendorlookup.com
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, true); // WIZnet interface with FEZ Connect
//NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac); //Assigns ip/subnet/gateway/mac to Wiznet
//NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 0, 1 }); //Sets Static DNS address
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port);
try
{
Dhcp.EnableDhcp(mac); //Used to check if there were any problems with the network settings (And at work)
}
catch
{
Debug.Print("Connection failed. Verify cable is connected and network is operational.");
}
Debug.Print("Current Time: " + DateTime.Now.ToString()); //displays current time in VS2010 output window
Internet updateTime = new Internet(); // Creates an instance of the class 'myTime' so it can be called for updating the RTC
updateTime.NTPTime("time-a.nist.gov", -300); // Calls function to Update RTC from an NTP server "time-a.nist.gov" and offsets time for CST
Debug.Print("Updated Time: " + DateTime.Now.ToString()); //displays updated time in VS2010 output window
//ERROR IS ON THIS TIMER OBJECT///////////////////////////////////////////////////
Timer Updatetimer = new Timer(new TimerCallback(UpdateTime), null, 1000, 2000); //
//////////////////////////////////////////////////////////////////////////////////
Debug.GC(true); // Enable Garbage Collector
Debug.EnableGCMessages(true); // Enable / Disable Garbage Collector Messages
Thread.Sleep(Timeout.Infinite);
}
static void UpdateTime()
{
Dhcp.ReleaseDhcpLease();
Dhcp.RenewDhcpLease();
Internet update = new Internet();
update.NTPTime("time-a.nist.gov", -300);
Debug.Print("Network now connected and time updated to:" + DateTime.Now.ToString());
}