我有一个数据网格和计时器的窗体。 我已经创建资源CalculationSheet和DUTCH 翻译 - 英国(默认) - 荷兰语计时器耗尽资源全球化
我开始在荷兰语中的应用。 当我选择一个新的记录消息框弹出窗口。 它显示正确的语言,荷兰语。 我也设置了计时器。
当计时器过去并再次显示消息框时,资源将以默认语言显示。
这里是主入口点的应用程序:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("nl", true);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
这里是回调代码:
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
// shows in UK
MessageBox.Show(Properties.Resources.CalculationSheet);
}
private void Form1_Load(object sender, EventArgs e)
{
List<CalculationSheet> calculationSheets = new List<CalculationSheet>();
calculationSheets.Add(new CalculationSheet("a"));
calculationSheets.Add(new CalculationSheet("b"));
calculationSheets.Add(new CalculationSheet("c"));
this.dataGridView1.DataSource = calculationSheets;
this.m_Timer = new System.Timers.Timer();
this.m_Timer.Enabled = false;
this.m_Timer.Interval = 5000;
this.m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
// shows in DUTCH
MessageBox.Show(Properties.Resources.CalculationSheet);
this.m_Timer.Enabled = true;
}
感谢您的快速反应。 – user1773744
@ user1773744 NP,我已经更新了更多的代码,具体说明如何捕获SynchronizationContext并将回调编组。 – casperOne