1
我需要通过以下int dldnow
sendData静态方法/委托。System.Threading.Timer TimerCallback委托与参数?
public int dldnow;
Timer timer = new Timer(new TimerCallback(sendData), null, 1000*30, 1000*30);
public static void sendData(object obj)
{
string imageCount = (string)dldnow;
string imageCountJson = wc.DownloadString("http://*********/u.php?count=" + imageCount);
}
正如答案中所述,只需将'dldnow'作为参数'state'(现在你写'null')。另一件事:你不需要完全写入新的TimerCallback(sendData)。从C#2开始,您只需编写'sendData'(这称为方法组转换)。 – 2013-04-10 16:19:32
正确的版本参数刷新http://stackoverflow.com/questions/15931850/timer-callback-delegate-doesnt-get-the-refreshed-value-from-parameter-on-every – 2013-04-10 17:04:57