[Mono-list] mod-mono-server2 with threadpool does not correct threadstatic

Adriaan van Kekem adriaanvk at gmail.com
Fri Jul 6 06:49:21 EDT 2007


Hi,

ok, great, it's better to explain why ;-)

I have implemented a scenario with using statement. So, i have created a
context object which is saved in your session. But it's possible to define a
sub-context, for a systemaccount to do some tasks. After the task has been
done, you revert to your own context:
using(Context c = new Context())
{
   //system account tasks
}
//your own tasks

In Context i have a threadstatic variable Context.Current, which gives you
your own context. This is also used in the transactionscope object of .net
2.0. So i use a Stack containing all contexts currently on stack. So, when
you stop your request, the stack is still not empty, because your own
context is not disposed (its saved in session object). So, when other user
is using your thread from pool, the stack is not empty!

Hopefully this gives you some information what i am doing. Thank you in
advance for your answer!

Adriaan



Michał Ziemski wrote:
> 
> Hi!
> 
> If you want your variable reset after each request why delare it static?
> 
> Pleas give some further details about what are you trying to accomplish,
> then maybe someone can point you to other solution.
> 
> Cheers!
> Michał Ziemski
> 
> Adriaan van Kekem pisze:
>> Hi,
>>
>> So, is there a possibility to solve this problem without manually
>> clearing
>> the stack by each new request in the global.asax? or is there no standard
>> way to solve this problem?
>>
>> greetings,
>>
>> Adriaan
>>
>>
>>
>> Robert Jordan wrote:
>>   
>>> Adriaan van Kekem wrote:
>>>     
>>>> Hi,
>>>>
>>>> I have a mono application running with mod_mono on mono 1.2.4. I have
>>>> created somewhere in my webapp a threadstatic variable, actually a
>>>> generic
>>>> stack with specific objects. No i am running my webapp, and seeing my
>>>> log
>>>> file, i see that sometimes the same thread is reused later. This is
>>>> logical,
>>>> because there is a threadpool containing all threads, using them later
>>>> again. But when i see that the same thread is reused, the threadstatic
>>>> variables are not reset. I don't know if this is a bug, from compiler
>>>> view
>>>> its right, because it's the same thread. But from webapplication view,
>>>> i
>>>> think this is not right. 
>>>>
>>>> Is there any solution for this, or have i to report this as a real bug?
>>>>       
>>> This is not a bug. As you said, the threads are reused. That's why
>>> the [ThreadStatic] fields are already initialized.
>>>
>>> Robert
>>>
>>> _______________________________________________
>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>
>>>
>>>     
>>
>>   
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 

-- 
View this message in context: http://www.nabble.com/mod-mono-server2-with-threadpool-does-not-correct-threadstatic-tf4034291.html#a11462163
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list