Transfer parameter in main method
-
when program startup, I will give a parameter to main meth. then this parameter will transfer to MainForm(parameter of "Application.Run" method). But if program has run, how fransfer this parameter or get the MainForm?
-
Do you mean you want send some values as parameters to Main? This can be done like: Goto "Project properties -> Debug -> command line arguments" and put values separated by space.
-
Well in that case, create a parameterized constructor of the form you are calling in Applicatio.Run() and send the values.
-
Thanks. But you said the way can achieve at startup only. If program has run, how send parameter?
-
Thanks. But you said the way can achieve at startup only. If program has run, how send parameter?
If the program is already running you still send the parameter the same way, the constructor. The only difference is that Application.Run() won't be calling that constructor. You will have to call it yourself, how is up to you.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
jason_mf wrote:
But you said the way can achieve at startup only. If program has run, how send parameter?
Didnt got that.
-
Because my winform program can run only instance. So I checked in main of program class. if there is a instance in proceeding, can I get the main form of this instance? Or other way?
What kind of information are you trying to pass, and when?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
If the program is already running you still send the parameter the same way, the constructor. The only difference is that Application.Run() won't be calling that constructor. You will have to call it yourself, how is up to you.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
What kind of information are you trying to pass, and when?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo