Multithreading Beginner question - Forms

Nov 12 2010 8:07 AM
Hello all, 
Been reading for some time now and thought I'd post a quickie. 
Why can I not open an instance of a form from within a child thread?
I can open it when not using multi threading so why can't I use threading to open a separate form?
The aim is to have one main form (form2) to do a DB update and a clock form (Clock) to display some graphics that will spiral around to show the processing time. 
Please help. 

Many thanks. 

Dan.  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;


namespace WindowsApplication5
{
    public partial class Form2 : Form
    {
        Thread thread1;        
        private bool _stopThreads = false;

        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            thread1 = new Thread(new ThreadStart(DisplayThread1));
        }

        private void GO_Click(object sender, EventArgs e)
        {
 
             thread1.Start();             
        }

        void DisplayThread1()
        {
                Clock ClockForm = new Clock();
                ClockForm.Show();            
        }
    }
}

Answers (3)