From 45ca80a494e0c9d2f202443b73092b2abef597fc Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Thu, 8 Feb 2018 21:44:28 +0100 Subject: [PATCH] Postpone language packs list population until control Load event --- .../DS4Forms/LanguagePackComboBox.Designer.cs | 1 + DS4Windows/DS4Forms/LanguagePackComboBox.cs | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs index 1ed1ff2..84e31df 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs @@ -55,6 +55,7 @@ this.Controls.Add(this.cbCulture); this.Controls.Add(this.label1); this.Name = "LanguagePackComboBox"; + this.Load += new System.EventHandler(this.LanguagePackComboBox_Load); this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.ResumeLayout(false); diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index b626f60..ae0ced5 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -78,19 +78,6 @@ namespace DS4Windows.DS4Forms { InitializeComponent(); cbCulture.Enabled = false; - - Task.Run(() => { - // Find available language assemblies and bind the list to the combo box. - cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); - cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; - - // This must be set here instead of Designer or event would fire at initial selected value setting above. - cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); - cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); - - cbCulture.Enabled = true; - LanguageListInitialized.SetResult(true); - }); } private BindingSource CreateLanguageAssembliesBindingSource() @@ -143,5 +130,21 @@ namespace DS4Windows.DS4Forms { SelectedValueChanged?.Invoke(this, e); } + + private void LanguagePackComboBox_Load(object sender, EventArgs e) + { + Invoke(new Action(() => { + // Find available language assemblies and bind the list to the combo box. + cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); + cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; + + // This must be set here instead of Designer or event would fire at initial selected value setting above. + cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); + cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); + + cbCulture.Enabled = true; + LanguageListInitialized.SetResult(true); + })); + } } }