Event not finished - Form Closing causes nullreference exception
-
Hello, I'm just looking for ideas/techniques to apply to form to handle logon running events and blocking the user from closing the form until those events are done. Is there some formal way to do this or is a just a matter of using boolean to indicate idle status, etc? Situation: - user clicks on button causing a transaction - while the event is processing the user clicks on the Close Button (X). - the transaction returns and starts processing. it is possible to get the close event to fire while the transaction reply is being processed. So reply is being processed, the close event starts cleaning up objects (set to nothing/dispose) and the event uses one of those objects and 'object not set'. Note: We are using bubble up error handling so the top of the stack is the button. but we are also using threadexception handling so it too would need to react accordingly. Thank you for your time... Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
-
Hello, I'm just looking for ideas/techniques to apply to form to handle logon running events and blocking the user from closing the form until those events are done. Is there some formal way to do this or is a just a matter of using boolean to indicate idle status, etc? Situation: - user clicks on button causing a transaction - while the event is processing the user clicks on the Close Button (X). - the transaction returns and starts processing. it is possible to get the close event to fire while the transaction reply is being processed. So reply is being processed, the close event starts cleaning up objects (set to nothing/dispose) and the event uses one of those objects and 'object not set'. Note: We are using bubble up error handling so the top of the stack is the button. but we are also using threadexception handling so it too would need to react accordingly. Thank you for your time... Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
Hi, the FormClosing event has a FormClosingEventArgs parameter; of interest are the CloseReason property, telling you why the form would close, and the Cancel property, which when set to true prevents the form closing. :)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
-
Hi, the FormClosing event has a FormClosingEventArgs parameter; of interest are the CloseReason property, telling you why the form would close, and the Cancel property, which when set to true prevents the form closing. :)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
Thank you for replying Luc... So basically i would need to create a variable to indicate i'm within a click event and check that flag within the closing event and if the flag is true, then cancel the close else let it happen. i was hoping for some flag that's built into indicate if any of the form's events are "busy"... thanks again.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous