geo zhou

geo zhou

  • NA
  • 3
  • 0

How to call a DLL with message loop

Mar 27 2007 6:05 PM
Hi
 I want to re-write a C# application(exe) to C# DLL. This application
starts by

           myApp.MainApplication app = new myApp.MainApplication();
           Application.Idle += new
EventHandler(app.myApp.OnApplicationIdle);
           Application.Run(app);

 But when I move all the code into a DLL and try to call the DLL from
a test program by
         myApp.MainApplication.Main(args);

 I got next error
  "Starting a second message loop on a single thread is not a valid
operation. Use Form.ShowDialog instead."

 I tried to change
    Application.Run(app);
 To
   app.ShowDialog();

 Error was gone but I can't get mouse event. Application was not
runing correctly.

I changed my test porgram
   Application.Run(new form1());
to
  Form myform = new Form1();
  myform.ShowDialog();

Same error message was returned.

 Anyone has any idea about it, or any related infomation is helpfull.
 Thanks!

Answers (2)