Design question for forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Reber

    #1

    Design question for forms

    I have an application that does not transition well between two forms. When
    the user starts the app my login form opens, after they login the main form
    then opens but there is a few seconds lag between when the login form closes
    and the main form opens. Is there a different ways to do this and still have
    my login form open first? Below is my Program.cuss code.

    frmLogin form = new frmLogin();
    Application.Run (form);

    if (form .DialogResult == DialogResult.OK )
    Application.Run (new frmMain(form.Ap pConnection));

    Also, I have some dialogs that after they are closed a potion of the form is
    still painted on the screen while some code is executed based on the
    selection in the dialog. Is there a way to make sure that the code that is
    executed after the close of the dialog does not start until after the dialog
    forms have be completely removed from the screen?

    Thanks

    Dan


  • Chris Dunaway

    #2
    Re: Design question for forms

    On Aug 22, 7:59 am, "Dan Reber" <dre...@nospam. comwrote:
    I have an application that does not transition well between two forms. When
    the user starts the app my login form opens, after they login the main form
    then opens but there is a few seconds lag between when the login form closes
    and the main form opens. Is there a different ways to do this and still have
    my login form open first? Below is my Program.cuss code.
    >
    frmLogin form = new frmLogin();
    Application.Run (form);
    >
    if (form .DialogResult == DialogResult.OK )
    Application.Run (new frmMain(form.Ap pConnection));
    >
    Also, I have some dialogs that after they are closed a potion of the form is
    still painted on the screen while some code is executed based on the
    selection in the dialog. Is there a way to make sure that the code that is
    executed after the close of the dialog does not start until after the dialog
    forms have be completely removed from the screen?
    >
    One thing is that there is no need to call Application.Run twice.
    Perhaps something like this will help:

    using (frmLogin form = new frmLogin()) {
    if (form.ShowDialo g() == DialogResult.OK )
    Application.Run (new frmMain(form.Ap pConnection));
    }

    Use the using keyword to make sure the login form is disposed.

    Don't know if this will solve your transition problem, but it might
    help.

    Chris

    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: Design question for forms

      Hi,


      "Dan Reber" <dreber@nospam. comwrote in message
      news:OU$gjyL5HH A.2108@TK2MSFTN GP02.phx.gbl...
      >I have an application that does not transition well between two forms.
      >When the user starts the app my login form opens, after they login the main
      >form then opens but there is a few seconds lag between when the login form
      >closes and the main form opens. Is there a different ways to do this and
      >still have my login form open first? Below is my Program.cuss code.
      >
      frmLogin form = new frmLogin();
      Application.Run (form);
      >
      if (form .DialogResult == DialogResult.OK )
      Application.Run (new frmMain(form.Ap pConnection));
      Why are you creating the form like that?

      DO instead
      if (form .DialogResult == DialogResult.OK )
      new frmMain(form.Ap pConnection).Sh ow();


      Comment

      • Dan Reber

        #4
        Re: Design question for forms

        I changed the code to

        using (frmLogin loginForm = new frmLogin())
        if (loginForm.Show Dialog() == DialogResult.OK )
        Application.Run (new frmMain(loginFo rm.AppConnectio n));

        it does not fix the transition issue but it makes more sense this way.

        Thanks

        Dan


        "Chris Dunaway" <dunawayc@gmail .comwrote in message
        news:1187791204 .294648.13880@q 3g2000prf.googl egroups.com...
        On Aug 22, 7:59 am, "Dan Reber" <dre...@nospam. comwrote:
        >I have an application that does not transition well between two forms.
        >When
        >the user starts the app my login form opens, after they login the main
        >form
        >then opens but there is a few seconds lag between when the login form
        >closes
        >and the main form opens. Is there a different ways to do this and still
        >have
        >my login form open first? Below is my Program.cuss code.
        >>
        >frmLogin form = new frmLogin();
        >Application.Ru n(form);
        >>
        >if (form .DialogResult == DialogResult.OK )
        > Application.Run (new frmMain(form.Ap pConnection));
        >>
        >Also, I have some dialogs that after they are closed a potion of the form
        >is
        >still painted on the screen while some code is executed based on the
        >selection in the dialog. Is there a way to make sure that the code that
        >is
        >executed after the close of the dialog does not start until after the
        >dialog
        >forms have be completely removed from the screen?
        >>
        >
        One thing is that there is no need to call Application.Run twice.
        Perhaps something like this will help:
        >
        using (frmLogin form = new frmLogin()) {
        if (form.ShowDialo g() == DialogResult.OK )
        Application.Run (new frmMain(form.Ap pConnection));
        }
        >
        Use the using keyword to make sure the login form is disposed.
        >
        Don't know if this will solve your transition problem, but it might
        help.
        >
        Chris
        >

        Comment

        • Dan Reber

          #5
          Re: Design question for forms

          Looks like I did not need to call Application.Run to open the dialog but
          don't I need to use it to open my main form? I tried your code and the form
          just opened and closed right away.

          Thanks

          Dan


          "Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
          message news:uq5KCdM5HH A.4928@TK2MSFTN GP05.phx.gbl...
          Hi,
          >
          >
          "Dan Reber" <dreber@nospam. comwrote in message
          news:OU$gjyL5HH A.2108@TK2MSFTN GP02.phx.gbl...
          >>I have an application that does not transition well between two forms.
          >>When the user starts the app my login form opens, after they login the
          >>main form then opens but there is a few seconds lag between when the login
          >>form closes and the main form opens. Is there a different ways to do this
          >>and still have my login form open first? Below is my Program.cuss code.
          >>
          >frmLogin form = new frmLogin();
          >Application.Ru n(form);
          >>
          >if (form .DialogResult == DialogResult.OK )
          > Application.Run (new frmMain(form.Ap pConnection));
          >
          Why are you creating the form like that?
          >
          DO instead
          if (form .DialogResult == DialogResult.OK )
          new frmMain(form.Ap pConnection).Sh ow();
          >

          Comment

          • =?Utf-8?B?WWFyb24gS2Fybmk=?=

            #6
            RE: Design question for forms

            Apply the mvc pattern, use an event sync the closing process and a controller
            which will listen to the evetn and apply the code.
            --
            Sincerely
            Yaron Karni
            All .net c# stuff, patterns code and snippet help programmer.



            "Dan Reber" wrote:
            I have an application that does not transition well between two forms. When
            the user starts the app my login form opens, after they login the main form
            then opens but there is a few seconds lag between when the login form closes
            and the main form opens. Is there a different ways to do this and still have
            my login form open first? Below is my Program.cuss code.
            >
            frmLogin form = new frmLogin();
            Application.Run (form);
            >
            if (form .DialogResult == DialogResult.OK )
            Application.Run (new frmMain(form.Ap pConnection));
            >
            Also, I have some dialogs that after they are closed a potion of the form is
            still painted on the screen while some code is executed based on the
            selection in the dialog. Is there a way to make sure that the code that is
            executed after the close of the dialog does not start until after the dialog
            forms have be completely removed from the screen?
            >
            Thanks
            >
            Dan
            >
            >
            >

            Comment

            • Ignacio Machin \( .NET/ C# MVP \)

              #7
              Re: Design question for forms

              Hi,

              "Dan Reber" <dreber@nospam. comwrote in message
              news:e25$QlM5HH A.464@TK2MSFTNG P02.phx.gbl...
              Looks like I did not need to call Application.Run to open the dialog but
              don't I need to use it to open my main form? I tried your code and the
              form just opened and closed right away.
              You only need to call Application.Run once in your program, to create the
              first form. Take a look at MSDN for a detailed explanation of what it does,
              basically it create a message pump that allows your forms to receive events.


              Comment

              • Dan Reber

                #8
                Re: Design question for forms

                OK, thanks for your help.

                "Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
                message news:%23QK$ULO5 HHA.4928@TK2MSF TNGP05.phx.gbl. ..
                Hi,
                >
                "Dan Reber" <dreber@nospam. comwrote in message
                news:e25$QlM5HH A.464@TK2MSFTNG P02.phx.gbl...
                >Looks like I did not need to call Application.Run to open the dialog but
                >don't I need to use it to open my main form? I tried your code and the
                >form just opened and closed right away.
                >
                You only need to call Application.Run once in your program, to create the
                first form. Take a look at MSDN for a detailed explanation of what it
                does, basically it create a message pump that allows your forms to receive
                events.
                >

                Comment

                Working...