Click here to Skip to main content
15,898,938 members
Home / Discussions / C#
   

C#

 
Questionshowing form from thread Pin
Sunshine Always13-May-10 1:15
Sunshine Always13-May-10 1:15 
QuestionRe: showing form from thread Pin
wasifmuneer13-May-10 1:45
wasifmuneer13-May-10 1:45 
AnswerRe: showing form from thread Pin
Sunshine Always13-May-10 2:09
Sunshine Always13-May-10 2:09 
AnswerRe: showing form from thread Pin
Luc Pattyn13-May-10 3:21
sitebuilderLuc Pattyn13-May-10 3:21 
AnswerRe: showing form from thread Pin
The Man from U.N.C.L.E.13-May-10 3:47
The Man from U.N.C.L.E.13-May-10 3:47 
GeneralRe: showing form from thread Pin
Sunshine Always14-May-10 1:41
Sunshine Always14-May-10 1:41 
GeneralRe: showing form from thread Pin
The Man from U.N.C.L.E.14-May-10 3:26
The Man from U.N.C.L.E.14-May-10 3:26 
AnswerRe: showing form from thread Pin
DaveyM6913-May-10 5:31
professionalDaveyM6913-May-10 5:31 
I'm not sure about the best practices where this is concerned. It's not something I would ever do so I haven't investigated and could maybe have some disasterous consequences. A quick test however reveals it works - I'm sure others will comment!
C#
using System;
using System.Threading;
using System.Windows.Forms;

namespace Forms_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Load += new EventHandler(Form1_Load);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(StartNewThread));
            thread.Start();
        }
        private void StartNewThread()
        {
            Application.Run(new Form2());
        }
    }
}

Edit: This MSDN[^] link may be of interest.
Dave

If this helped, please vote & accept answer!


Binging is like googling, it just feels dirtier. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

GeneralRe: showing form from thread Pin
The Man from U.N.C.L.E.13-May-10 6:43
The Man from U.N.C.L.E.13-May-10 6:43 
GeneralRe: showing form from thread Pin
DaveyM6913-May-10 9:24
professionalDaveyM6913-May-10 9:24 
AnswerRe: showing form from thread Pin
#realJSOP13-May-10 6:28
professional#realJSOP13-May-10 6:28 
AnswerRe: showing form from thread Pin
AspDotNetDev13-May-10 11:31
protectorAspDotNetDev13-May-10 11:31 
GeneralRe: showing form from thread Pin
Dave Kreskowiak13-May-10 12:48
mveDave Kreskowiak13-May-10 12:48 
GeneralRe: showing form from thread Pin
AspDotNetDev13-May-10 18:18
protectorAspDotNetDev13-May-10 18:18 
GeneralRe: showing form from thread Pin
Dave Kreskowiak13-May-10 18:47
mveDave Kreskowiak13-May-10 18:47 
GeneralRe: showing form from thread Pin
AspDotNetDev13-May-10 18:49
protectorAspDotNetDev13-May-10 18:49 
GeneralRe: showing form from thread Pin
Dave Kreskowiak13-May-10 19:25
mveDave Kreskowiak13-May-10 19:25 
GeneralRe: showing form from thread Pin
The Man from U.N.C.L.E.13-May-10 22:34
The Man from U.N.C.L.E.13-May-10 22:34 
GeneralRe: showing form from thread Pin
The Man from U.N.C.L.E.13-May-10 22:43
The Man from U.N.C.L.E.13-May-10 22:43 
QuestionShowFileDialog In Console Pin
noamtzu0013-May-10 0:00
noamtzu0013-May-10 0:00 
AnswerRe: ShowFileDialog In Console Pin
Michel Godfroid13-May-10 0:36
Michel Godfroid13-May-10 0:36 
GeneralRe: ShowFileDialog In Console Pin
Luc Pattyn13-May-10 3:30
sitebuilderLuc Pattyn13-May-10 3:30 
RantRe: ShowFileDialog In Console Pin
Michel Godfroid13-May-10 4:13
Michel Godfroid13-May-10 4:13 
GeneralRe: ShowFileDialog In Console Pin
Luc Pattyn13-May-10 4:40
sitebuilderLuc Pattyn13-May-10 4:40 
GeneralRe: ShowFileDialog In Console Pin
Michel Godfroid13-May-10 5:06
Michel Godfroid13-May-10 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.