私は今、次のコードを持っています。それ以外の場合は機能していますが、picturesDownloaded更新されません。その 5 秒間で sendData は呼び出されず、picturesDownloaded別の値を取得します。タイマーが実行されるたびに更新する方法は? したがって、それobj.ToString()が正しい値になります。
あるポイントでpicturesDownloadedは値「11」を取得しますobject objが、値は「0」のままです。
public static volatile string picturesDownloaded = "0";
System.Threading.Timer timer = new System.Threading.Timer(sendData, picturesDownloaded, 1000 * 5, 1000 * 5);
public static void sendData(object obj)
{
WebClient wc = new WebClient();
string imageCountJson = wc.DownloadString("http://******/u.php?count=" + obj.ToString());
}