I run the following test page. It seems that culture for the 2 threads are different. The async thread does not use the culture defined in the page directive. Is this behaviour by design or a bug?
<%@ Page Language="C#" AutoEventWireup="true" Culture="nl-BE" UICulture="nl-BE" %>
<%@ Import Namespace="System.Threading" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script runat="server" language="C#">
private delegate void TestFormattingDelegate();
private TestFormattingDelegate doTestFormmattingDelegate;
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(string.Format("Culture : {0}", Thread.CurrentThread.CurrentCulture.ToString()));
Response.Write("<br/>");
Response.Write(string.Format("UI culture : {0}", Thread.CurrentThread.CurrentUICulture.ToString()));
Response.Write("<br/>");
Response.Write(string.Format("Page culture : {0}", Page.Culture));
Response.Write("<br/>");
GoAsync();
}
private void GoAsync()
{
PageAsyncTask taskTestFormatting = new PageAsyncTask(
new BeginEventHandler(TestFormattingBeginAsyncOp),
new EndEventHandler(TestFormattingEndAsyncOp),
new EndEventHandler(TestFormattingTimeoutAsyncOp),
null,
true);
this.RegisterAsyncTask(taskTestFormatting);
}
private void TestFormatting()
{
Response.Write(string.Format("Async Culture : {0}", Thread.CurrentThread.CurrentCulture.ToString()));
Response.Write("<br/>");
}
IAsyncResult TestFormattingBeginAsyncOp(object sender, EventArgs e, AsyncCallback cb, object state)
{
doTestFormmattingDelegate = new TestFormattingDelegate(TestFormatting);
return doTestFormmattingDelegate.BeginInvoke(cb, state);
}
private void TestFormattingEndAsyncOp(IAsyncResult result)
{
}
private void TestFormattingTimeoutAsyncOp(IAsyncResult result)
{
}
</script>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>