.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Async client & CurrentCulture
 

Async client & CurrentCulture

Hello,

The callback I pass to my Begin method seems not to inherit the culture of my main executable.
I suppose it is because it runs on an other thread.
Is there a clean way to let the callback run with the same culture as the parent process ?

Thanks
philippe
philippe lombaers
Hi Philippe,

Please give more information so as to reproduce your scenario. Without the detailed information, we often don't know your scenario.

You can check Thread. ManagedThreadId property to check which thread callback is run. You also can set its culture in Callback operation to implement your requirement.



Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong
Hello,

My scenario is as follows :

This thread runs with "fr-BE" culture.
proxy.BeginBlabla(OnBlablaComplete, null);

This thread seems to run with the default culture.
private
static void OnBlablaComplete(IAsyncResult ar)
{
try
{
proxy.EndBlabla(ar);
}
catch (Exception ex)
{
THIS IS SHOWN WITH WRONG LANGUAGE (DEFAULT)
MessageBox.Show(Properties.Resources.Message);
}
}
I'd like to have a way to make OnBlablaComplete run with the same culture as the rest of the process.

Thanks for your help.


philippe
philippe lombaers
Hi Philippe,

Whether you modify the culture of main thread in this scenario. You just also use the following code snippet to modify the culture in Callback function to implement your requirement.

CultureInfo culture4 = new CultureInfo("fr-BE");
System.Threading.Thread.CurrentThread.CurrentCulture = culture4;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture4;
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong
Hello,

Is there a more elegant way to achieve this (wcf behaviour, ...) ?
I have tons of scenario like this and it would take me a while to change all callbacks.

Thanks
philippe
philippe lombaers
Hi Philippe,

I didn't see there is any other methods for customizing culture in this scenario. You also need to manually modify the thread culture for callback procedure.

Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong

You can use google to search for other answers

Custom Search

More Threads

• IIS hosting error
• DataMember Attribute declaration - On Member Variable or Property?
• ASP.NET client with WIndows Integrated AUthentication service
• consuming ssl service through a xbap client
• Deploying WCF app on a computer without .NET 3.0 installed
• Java X WCF Service
• Problem to process a fault generated by a axis web service implementation.
• WCF Service - WSIT Client Problem on Windows Vista
• Accelerate Proxy Generation
• How much security do I need to protect me?