Hi,
Are there any other places where you call the increaseCounter method? Or are there any other ways in which you change the Cache?
I suggest you place the "lock" in the increaseCounter method,like this:
public static string increaseCounter(string data)
{
int counter;
lock (lockObj)
{counter = (int)HttpRuntime.Cache["Counter"];
++counter;HttpRuntime.Cache.Insert("Counter", counter);
}
return Convert.ToString(counter);}
public static Object lockObj=new Object();
[System.Web.Services.WebMethod]
public static string iCounter()
{
return increaseCounter();
}
Best Regards,
0 件のコメント:
コメントを投稿