Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run form in separate thread
Message
From
17/07/2010 05:53:49
 
 
To
17/07/2010 03:40:35
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01472778
Message ID:
01472779
Views:
43
>Hi,
>I have a FORM1
>
>In Form1.somefunction() - I create PROGRESSBAR (FORM2) . and update progress,captions and so on
>then in somefunction I close FORM1, but I want leave PROGRESSBAR (FORM2) open even if the form was closed.
>
>Now when my FORM1 is closed, form2 is also closing.
>
>How to make this?

Simple way:
   public class MyContext : ApplicationContext
    {
        [STAThread]
        static void Main()
        {
            MyContext context = new MyContext();
            Application.Run(context);
        }
        
        MyContext()
        {
            Form1 f1 = new Form1();
            f1.Show();
        }
    }
To close the application you will need a 'Application.ExitThread()' somewhere.....
Or:
private void button_Click(object sender, EventArgs e)
        {
            System.Threading.Thread t =
                new System.Threading.Thread(new System.Threading.ThreadStart(RunForm));
            t.Start();
        }

        private void RunForm()
        {
            Form f1 = new Form();
            f1.ShowDialog();
        }
Previous
Reply
Map
View

Click here to load this message in the networking platform