Reputation: 6908
So, management has decided to implement an idea to allow the user to choose the language for the program. And the way they want it is, in my opinion, silly. But, I can't change their mind. Here's how it works. The main form(frmMain
) will start to load. Before the InitializeComponent()
, they want another form(frmLanguage
) to load asking the user to select a language. Now, I can get frmLanguage to pop up at the proper time. My problem is, how do I prevent or pause frmMain from continuing to load once I've got frmLanguage displayed?
public FrmMain()
{
var language = new FrmLanguage();
language.Show();
// I need to pause the FrmMain right here
InitializeComponent();
}
I was thinking that threading might be the way to do this, but I've got zero experience with it, so I'm unsure that's even a correct line of thinking. I don't want to do a Sleep()
or similar, cause who knows how long the user will take to enter their choice. Also, this will be a one-off popup. I'll be changing a line in a pre-existing INI file so that this won't pop up if they've already selected a language. Thanks for any and all help.
Upvotes: 0
Views: 184
Reputation: 2869
I'm not sure if this will work, so just let me know if it helps you.
In your Main() method, you could load the first form with:
Application.Run(new FrmLanguage());
Then from that form gather the language setting, and load the other form like normal.
Upvotes: 0
Reputation: 2970
It's a little dangerous to put code before InitializeComponent
- you'll run into NullReferenceException
s if you forget to avoid trying to touch controls on your form. Updating member fields is OK, though.
Could the code that loads FrmMain
load and execute FrmLanguage
first, perhaps near the place where the INI file is checked?
Upvotes: 0