i have 2 c# winform (.net 4.0) forms each run separate similar automated tasks continuously. separate in distinct processes/workflows, similar enough in how operate share same resources (methods, data models, assemblies, etc) in project.
both forms complete, i'm not sure how run program each window opens on launch , runs independently. program "always-on" when deployed.
this might seem little basic, of development experience has been web applications. threading/etc still little foreign me. i've researched of answers i've found relate user interaction , sequential use cases -- 1 system continuously running 2 distinct processes, need interact world independently.
potential solutions i've found might involve multi-threading, or maybe kind of mdi, or few folks have suggested dockpanelsuite (although being in super-corporate environment, downloading third party files easier said done).
static class program { /// <summary> /// main entry point application. /// </summary> [stathread] static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); // rather specifying frmone or frmtwo, // load both winforms , keep them running. application.run(new frmone()); } }
you can create new applicationcontext
represent multiple forms:
public class multiformcontext : applicationcontext { private int openforms; public multiformcontext(params form[] forms) { openforms = forms.length; foreach (var form in forms) { form.formclosed += (s, args) => { //when have closed last of "starting" forms, //end program. if (interlocked.decrement(ref openforms) == 0) exitthread(); }; form.show(); } } }
using can write:
application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new multiformcontext(new form1(), new form2()));
Comments
Post a Comment