locked
How to call a form in a separate thread? RRS feed

  • Question

  • Hi Experts,

    I want to display a new form for few seconds after I clicked login button in login form.  After few seconds it should go to my application's first form. How can I achieve this?

    I am new to smart device development in C#.

    I am struck in this part.

    Can anyone help me out in this.

    Regards,

    Angelin Nithya.

     

     

     

    Friday, June 4, 2010 10:30 AM

Answers

  • worker threads and UI threads don't mix. If a worker thread interacts with a UI object directly your program will misbehave or crash. 

    But for this problem you don't need another thread.  You could have the first form of your application start and within it's load event have it show the login form. If your login form were named MyLoginForm then you could do something like the following:

    void Form1_Load(object sender, EventArgs args)
    {
       MyLoginForm myForm = new MyLoginForm();
       if(myForm.ShowDialog()==DialogResult.OK)
       {
         //access the data from your form here
       }
    }


    Joel Ivory Johnson | http://www.j2i.net | Device Application Development MVP
    It takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.
    Friday, June 4, 2010 1:06 PM