CurrentThread question

H

Hardy Wang

Hi,
I have a web service, which calls one class to do all detailed jobs. In this
class, I need to handle globalization problems by running
Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
My question is, by running this, the culture changing will affect the whole
web service or only this initialized instance?

Thanks!
 
R

Rick Strahl [MVP]

It will only affect the current thread (if it's the ASP.Net thread that is)
and it willl reset to default locale after the request is done.

So if your code changes it and then continues on you may have to reset the
locale when your component is done. This is easy though - just save the
locale id, then reset when done.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 
B

bruce barker

it only effects the current thread, which will be returned to the pool (so
be sure to restore it). if you use any of the webservice async features,
you are not guaranteed the same thread for the completed web request, so you
need to be careful.


-- bruce (sqlwork.com)
 
J

Jon Skeet [C# MVP]

Hardy Wang said:
I have a web service, which calls one class to do all detailed jobs. In this
class, I need to handle globalization problems by running
Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
My question is, by running this, the culture changing will affect the whole
web service or only this initialized instance?

Others have provided an answer about the thread, but I'm concerned by
your statement that you *need* to handle globalization by changing the
current thread's culture. Which culture-sensitive methods do you need
to call which don't have an override which states which culture to use?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top