In a WCF being run from IIS I have this code (well something similar).
public static class Test
{
public static int Method(int x, int y)
{
int p = 10;
int r = p * x * y;
return r;
}
}
This method can then in theory be called from 1 million requests from 1 million different users simultaneously.
I have an argument discussion with a colleague where my stand point is that each instance of this method call is separate and will never cause data corruption between calls. This is supported by this thread: C# : What if a static method is called from multiple threads?
My colleague however claims that IIS and WCF are a special kind of monster that can cache and start/stop calls in all kinds of weird places so that in practice these calls actually can interfer with one another.
The example he made was that if one call is inside the method and another one comes in with new paramaters then the int x
and int y
paramater variables values could potentially be replaced for the already ongoing call.
His stand point is NEVER use static
methods / classes in anything IIS / WCF related.
I haven't been able to find any solid documentation that supports either case, anyone care to throw some well documentet arguments at this?