Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I just have a MainForm and 9 User control inside the Mainform.
I need to open 9 applications (1 application per UserControl).

What I have tried:

<pre>public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            int count = 9;
            for (int i = 0; i < count; i++)
            {
                RfControl rfc = new RfControl();
                rfc.gTitle.Text = "Device" + Convert.ToString((i + 1));
                this.flowLayoutPanel1.Controls.Add(rfc);
            }
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            for(int i=0; i<this.flowLayoutPanel1.Controls.Count; i++)
            {
                RfControl rfc = (RfControl)this.flowLayoutPanel1.Controls[i];
            }
        }

        private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
Posted
Updated 23-Sep-20 4:49am
Comments
OriginalGriff 23-Sep-20 10:23am    
And?
What have you tried?
Where are you stuck?
What help do you need?
Mohammad Razmi 23-Sep-20 10:27am    
Hello sir. I actually don't know what to in order to reach my goal (9 application for my frmmain).
when I start my application just one application and process open in my windows task manager.
I would like to open 9 of the same program.
Richard MacCutchan 23-Sep-20 10:30am    
Then just click on the app 9 times.
Mohammad Razmi 23-Sep-20 10:32am    
I don’t want it...
I just need the same application to run from another thread for each UserControl (9 of them are present in the my mainform)
Richard MacCutchan 23-Sep-20 10:37am    
Use the Process Class (System.Diagnostics) | Microsoft Docs[^] to create each application.

1 solution

Threads and Processes are different from applications!
If you have an application (i.e. an EXE file) you want to run each time you create a control instance, then the control needs to call Process.Start:
C#
Process.Start("MyApp.exe", "my app parameters");

Process.Start Method (System.Diagnostics) | Microsoft Docs[^] or one of it's overloads, or create a Process instance for finer control.

If you have a task you want to run in the background within your control but the code is built into the control's assembly, then you need a Thread, and I'd recommend startith with a BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^] instance.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900