C# – static methods and the call stack in IIS/asp.net

asp.netccallstackiisstatic methods

Theoretical question.
If you have 100 separate requests coming to an aspx web page that calls the static method below.

    public static GeocodeResult GeocodeQuery(string query)
    {
        int train, tube, dlr = 0;

        // manipulate these ints
        if (train)
        {
            // do something important
        }

    }

Does every request have a separate call stack?

If so –
Does this static method call get pushed on these separate call stacks?

If so –
Therefore are these ints thread safe? ie. 100 requests, 100 call frames, 300 ints.

Cheers

Best Answer

Yes, each request has it's own call stack. And each stack will contain it's own values for query, train, tube, dir, since local variables and method parameters are stored in stack.

So, unless you are accessing some shared state, this method is thread safe.