0

The two forms need to run at the same time. below showed the code from project1

static void Main()
{
    eyeXHost.Start();
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    var f = new cursor();
    f.Show();
    Application.Run(new eye());

    eyeXHost.Dispose();
}

Then I need to run cursor and eye form at the same time at project 2. I did try out this method below in project2.

static void EyeTrackerMode()
{
    eye_tracker = new eyetracker();
    Application.Run(new eye());
    Application.Run(new cursor());                 
}

The debug only show one form which is the "eye". Please lend me a hand on this. Thank you.

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
sing
  • 1
  • 1
  • 1
    `Form2 form2 = new Form2(); form2.Show(); Application.Run(new eye());` ? – mrogal.ski Dec 08 '16 at 08:21
  • Hi, Mong Zhu, thanks for your solution, your method is working. However, it does not transfer the function I set in the eye form to the startup project. – sing Dec 08 '16 at 09:53
  • `Application.Run(...)` is synchronous call so every line after that will be called when previous form is closed. Only solutions that i can think of right now is to create two "UI" threads with shared memory and start thease two forms as a separate "Application" or just show 2 forms at once and place one of them into `Application.Run(...)` method. – mrogal.ski Dec 08 '16 at 09:59
  • Hi, thanks for your reply. But I don't get it how to create two "UI" threads. Can you show some examples? – sing Dec 08 '16 at 10:07
  • [Example of multiple UI threads](http://stackoverflow.com/questions/7568376/multiple-ui-threads-winforms) – mrogal.ski Dec 08 '16 at 10:11

0 Answers0