0

I had originally created a windows form to be a dialog of my projects main form. Now the dialog is getting complex enough that it needs to be started in its own process. Is there a way to do this in code or do i need to create a new project and link my files to it?

Mike_G
  • 16,237
  • 14
  • 70
  • 101
  • 1
    Can you clarify for me why you need the form in a seperate process? This will lead to difficulties (not insurmountable, but inefficient) in sharing information between the form and the rest of the app... If this is just because the form is going a lot of computation for example, have you considered multi-threading? – Martin Milan Jun 15 '10 at 21:52
  • It is related to this: http://stackoverflow.com/questions/3026294/decompressing-a-very-large-serialized-object-and-managing-memory essentially, when i close out my dialog, even though I have made sure that Dispose is called on it, the CPU will sit and spin at 50%. – Mike_G Jun 15 '10 at 21:57

2 Answers2

3

I question the premise here - there is no reason to necessarily start a new "form" in a separate process. If the form is getting that complex, however, I would recommend simplifying it, if for no reason other than usability.

That being said, you can always launch a new process via Process.Start in code. If you want it to be in the same project, but start a separate process, you could launch the executing exe with a command line argument that allows you to switch which "form" is loaded at startup.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
1

You will need to set up a communication layer (WCF using named pipes would probably be the best way to go).

But I would seriously question why you need a new process for your form? Make sure that whatever work you do on your form is done on a separate thread. That way you can have dozens of forms open but your app will remain very responsive.

It's not the best solution, but if you are trying to avoid a rewrite, a call to Application.DoEvents will pump the message queue and get you some responsiveness back if you have a whole lot of updates happening on your UI. Band aid solution to your problem though.

Spence
  • 28,526
  • 15
  • 68
  • 103