Closing Event

  • Thread starter Steven Spencer \(Spinalogic\)
  • Start date
S

Steven Spencer \(Spinalogic\)

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.
 
G

Guest

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.
 
S

Steven Spencer \(Spinalogic\)

Thats a bloody good idea smartarse.

;P

Sorry but you seriously just owned me, that is a fantastic idea for
debugging purposes!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top