CurrentThread question

Discussion in 'ASP .Net' started by Hardy Wang, Apr 26, 2004.

  1. Hardy Wang

    Hardy Wang Guest

    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!

    --
    WWW: http://hardywang.1accesshost.com
    ICQ: 3359839
    yours Hardy
     
    Hardy Wang, Apr 26, 2004
    #1
    1. Advertising

  2. 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/
    ----------------------------------
    Making waves on the Web


    "Hardy Wang" <> wrote in message
    news:...
    > 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!
    >
    > --
    > WWW: http://hardywang.1accesshost.com
    > ICQ: 3359839
    > yours Hardy
    >
    >
     
    Rick Strahl [MVP], Apr 26, 2004
    #2
    1. Advertising

  3. Hardy Wang

    bruce barker Guest

    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)



    "Hardy Wang" <> wrote in message
    news:...
    > 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!
    >
    > --
    > WWW: http://hardywang.1accesshost.com
    > ICQ: 3359839
    > yours Hardy
    >
    >
     
    bruce barker, Apr 26, 2004
    #3
  4. Hardy Wang <> wrote:
    > 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?

    --
    Jon Skeet - <>
    http://www.pobox.com/~skeet
    If replying to the group, please do not mail me too
     
    Jon Skeet [C# MVP], Apr 27, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clive
    Replies:
    1
    Views:
    666
    Sherif ElMetainy
    Aug 28, 2003
  2. Zalek Bloom
    Replies:
    14
    Views:
    708
    Michael Borgwardt
    Nov 21, 2003
  3. Gonzalo Moreno
    Replies:
    2
    Views:
    12,572
  4. Gleb
    Replies:
    2
    Views:
    12,619
    PerfectDayToChaseTornados
    Nov 11, 2004
  5. JohnnyV

    Thread.CurrentThread.CurrentCulture

    JohnnyV, Feb 9, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    211
    JohnnyV
    Feb 9, 2004
Loading...

Share This Page