[Mono-dev] set culture uses serialization?

Steve Bjorg steveb at mindtouch.com
Sun Jan 6 00:22:44 EST 2008

On Jan 5, 2008, at 9:09 PM, Miguel de Icaza wrote:

>> That only leaves the issue with using serialization when setting
>> CurrentCulture.  Is that by design or a bug?  If by design, what is
>> the recommended pattern for supporting difference cultures on
>> different threads?
> Is this leading to a crash or a performance concern?

It's primarily performance driven, although, we did encounter a crash  
as well, which revealed that the CultureInfo instance was serialized  
when setting Thread.CurrentUICulture.  However, Robert Jordan  
indicated that the cause for the crash had been addressed in 1.2.6.

A stack trace was captured here:

> I have not investigated what Microsoft does in the particular scenario
> that you are running into (where you handle some of the work on async
> thread callbacks).

I did not check if .Net did anything special for async ops.  I  
assumed it would not and decided to automatically "float" the  
thread's CultureInfo from the point of initiation (BeginXYZ) to its  
completion handler (EndXYZ).  Potentially, this will set the culture  
more often than its needs to, but is ensure that it is set  
consistently across threads.  Hence the performance concern if  
serialization is used to do an operation I thought was nothing more  
than setting the an object reference on a thread static variable.

- Steve

Steve G. Bjorg

More information about the Mono-devel-list mailing list