PC Review


Reply
Thread Tools Rate Thread

Closing Event

 
 
Steven Spencer \(Spinalogic\)
Guest
Posts: n/a
 
      31st Jan 2007
Gday,

I'm a java developer turned .net developer, and I'm unfamiliar with some
concepts, especially the event loop.

We have a form in which upon closing needs to save a significant amount of
data, and perform some thread cleanup etc for long running tasks. We have
added a handler to the "closing" event on the form to do this. Occasionally
on exiting the form (not shown modally) we end up with our dataset (which is
perfectly accessed up to two or three times before) coming up with a null
reference exception. What I wanted to know is how the event handler works?
Does it wait for all registered handlers of the event to execute and THEN
dispose the form? Or does it simply dispose at some point after calling the
closing method.

IF someone knew a good tute to understand the message loop on the winforms,
that would be great too.

PS forgive me if this is a primitive question.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
Posts: n/a
 
      31st Jan 2007
The is (normally) only one thread processing the message loop in winforms,
commonly named the "ui thread". This will process each subscriber to teh
Closing event in turn, then close the form.
My guess would be the cleanup code is assigning the null to the dataset. You
could potentially try wrapping the dataset in a property. Then putting a
breakpoint in the set method and seeing if it is explicitly set to null. The
stackframe window would enable you to look up the stack at where in your code
it was done.


--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


"Steven Spencer (Spinalogic)" wrote:

> Gday,
>
> I'm a java developer turned .net developer, and I'm unfamiliar with some
> concepts, especially the event loop.
>
> We have a form in which upon closing needs to save a significant amount of
> data, and perform some thread cleanup etc for long running tasks. We have
> added a handler to the "closing" event on the form to do this. Occasionally
> on exiting the form (not shown modally) we end up with our dataset (which is
> perfectly accessed up to two or three times before) coming up with a null
> reference exception. What I wanted to know is how the event handler works?
> Does it wait for all registered handlers of the event to execute and THEN
> dispose the form? Or does it simply dispose at some point after calling the
> closing method.
>
> IF someone knew a good tute to understand the message loop on the winforms,
> that would be great too.
>
> PS forgive me if this is a primitive question.
>
>
>

 
Reply With Quote
 
Steven Spencer \(Spinalogic\)
Guest
Posts: n/a
 
      1st Feb 2007
Thats a bloody good idea smartarse.

;P

Sorry but you seriously just owned me, that is a fantastic idea for
debugging purposes!
"Ciaran O''Donnell" <(E-Mail Removed)> wrote in
message news:C37FE663-1110-4CF8-AA21-(E-Mail Removed)...
> The is (normally) only one thread processing the message loop in winforms,
> commonly named the "ui thread". This will process each subscriber to teh
> Closing event in turn, then close the form.
> My guess would be the cleanup code is assigning the null to the dataset.
> You
> could potentially try wrapping the dataset in a property. Then putting a
> breakpoint in the set method and seeing if it is explicitly set to null.
> The
> stackframe window would enable you to look up the stack at where in your
> code
> it was done.
>
>
> --
> Ciaran O''Donnell
> http://wannabedeveloper.spaces.live.com
>
>
> "Steven Spencer (Spinalogic)" wrote:
>
>> Gday,
>>
>> I'm a java developer turned .net developer, and I'm unfamiliar with some
>> concepts, especially the event loop.
>>
>> We have a form in which upon closing needs to save a significant amount
>> of
>> data, and perform some thread cleanup etc for long running tasks. We
>> have
>> added a handler to the "closing" event on the form to do this.
>> Occasionally
>> on exiting the form (not shown modally) we end up with our dataset (which
>> is
>> perfectly accessed up to two or three times before) coming up with a null
>> reference exception. What I wanted to know is how the event handler
>> works?
>> Does it wait for all registered handlers of the event to execute and THEN
>> dispose the form? Or does it simply dispose at some point after calling
>> the
>> closing method.
>>
>> IF someone knew a good tute to understand the message loop on the
>> winforms,
>> that would be great too.
>>
>> PS forgive me if this is a primitive question.
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing event =?Utf-8?B?QWwgdGhlIHByb2dyYW1tZXI=?= Microsoft C# .NET 6 8th Apr 2005 04:13 PM
event on DB closing =?Utf-8?B?cm9jY28=?= Microsoft Access VBA Modules 3 18th Mar 2005 03:52 AM
Do I need to override the OnClosing event when I'm closing a thread or would the Form_Closing event would work fine? Asheesh Microsoft Dot NET Compact Framework 2 6th Feb 2004 06:28 AM
Closing Event Clyde Microsoft Dot NET Framework Forms 2 5th Jan 2004 09:55 PM
Closing event Randy Microsoft C# .NET 0 12th Nov 2003 06:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:43 AM.