On Mon, 6 May 2002 13:00:15 -0400, Peter Schroeder <[EMAIL PROTECTED]> wrote:

I pulled he book off the shelf and cheked it out. Behold ! there it was
page 312, that's awesome that you could remember not only that you read it
somewhere , but actually which book it was! Most people (ME) keep a lot of
books and information on hand, but when I go "I remember reading about that
topic somewhere, Now where was that ? " I usually have to go search through
several candidate books, papers, until I stumble on it again.

Thanks, that passage was exactly what I was referring to.

That's the kind of collaboration, help that makes one appreciate the value
of lists like these.

KC

>KC,
>
>The Petzold book [1] recommends overriding the protected method OnLoad
(page
>312) for doing this type of work.  This method is called before the form is
>visible on screen, you can successfully call the Close method as well.
>
>Pete
>
>[1]
>http://www.amazon.com/exec/obidos/ASIN/0735613702/qid=1020704369/sr=8-
1/ref=
>sr_8_67_1/002-9329452-2169629
>
>
>----- Original Message -----
>From: "Curtis Koppang" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Monday, May 06, 2002 10:18 AM
>Subject: Re: [DOTNET] Close() in mainform constructor
>
>
>> I don't find this suprising.  We use a two phase construction pattern to
>> work around issues like this.  The constructor does stuff which gets the
>> class up an running (at a system level) but does not depend on many (as
>> close to zero as possible) external dependencies.  Then you call a custom
>> constructor which does the application level code - which is in ~some~
>sense
>> business logic.  I believe this is the model other frameworks (i.e. MFC)
>> have recommended.
>>
>> So the code which creates the form would look something like the
>> following...
>>
>> class Controller
>> {
>>     MainForm myMainForm;
>>
>>     public Form GetMainForm()
>>     {
>>         // could throw and execption, but if it does you won't have class
>>         myMainForm = new MainForm();
>>
>>         try
>>         {
>>             // do the application logic
>>             myMainForm.SecondaryConstructor();
>>         }
>>         finally
>>         {
>>             // if it fails we need to blow away the instance
>>             myMainForm = null;
>>         }
>>
>>         return myMainForm;
>>     } // ShowForm
>> } // Controller
>>
>>
>> Hope this helps,
>> curt
>>
>>
>> ----- Original Message -----
>> From: "K C" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Monday, May 06, 2002 8:58 AM
>> Subject: [DOTNET] Close() in mainform constructor
>>
>>
>> > In my application the constructor of the main form goes through its'
>usual
>> > routine, if something critical happens like a missing important file, I
>> > call the Close() method of the form to quit immediately. I get a
dispose
>> > exception, I can't seem to quit the application while im in the
>> > constructor. Anyone know the best way to do this?
>> >
>> > Thanks
>> > KC
>> >
>> > You can read messages from the DOTNET archive, unsubscribe from DOTNET,
>or
>> > subscribe to other DevelopMentor lists at http://discuss.develop.com.
>> >
>> >
>>
>> You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
>> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to