Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

Closing Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven Spencer (Spinalogic) - 31 Jan 2007 01:23 GMT
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.
Ciaran O''Donnell - 31 Jan 2007 13:12 GMT
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.

Signature

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

> Gday,
>
[quoted text clipped - 15 lines]
>
> PS forgive me if this is a primitive question.
Steven Spencer (Spinalogic) - 01 Feb 2007 00:43 GMT
Thats a bloody good idea smartarse.

;P

Sorry but you seriously just owned me, that is a fantastic idea for
debugging purposes!
> The is (normally) only one thread processing the message loop in winforms,
> commonly named the "ui thread". This will process each subscriber to teh
[quoted text clipped - 34 lines]
>>
>> PS forgive me if this is a primitive question.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.