0

How can i set MdiParent of a form that run on different Thread?

 Form2 _frmloading;
        private void thread2()
        {
            _frmloading = new Form2();
            _frmloading.TopMost = false;
            _frmloading.ShowInTaskbar = false;
            //Doesn't Work
            //MethodInvoker method = new MethodInvoker(delegate
            //    {
            //        _frmloading.MdiParent = this;
            // });
            // method.Invoke();

            //what do i write here?

            _frmloading.ShowDialog();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Thread LoadThread = new Thread(new ThreadStart(thread2));
            LoadThread.SetApartmentState(ApartmentState.STA);
            LoadThread.Start();
        }

This is possible?

KF2
  • 9,887
  • 8
  • 44
  • 77
  • I'v no idea why your aim is or... but pass form1(this) to form2 as property and use that in overridden OnLoad method in Form2, protected override void OnLoad(EventArgs e) { MdiParent = parentForm; base.OnLoad(e); } – Thunder-KC Inc Dec 08 '12 at 13:08
  • That's not possible, an MDI child **must** be owned by the same thread that owns the MDIParent. – Hans Passant Dec 08 '12 at 15:09

0 Answers0