P
Pat Reddy
I have a relatively simple single threaded application written in
VB.NET. When I close the application I loop through all open forms and
close them, like this basically
dim f as Form
for each f in forms
f.close()
Next
I heard this was better than using Application.Exit.
But, regardless of which I use, if I try to exit this way from a module,
like my DataAccess module upon an error connecting to a database for
example, all the forms close but the code that called the database
connection sub in my module continues to run. Here is some code...
Report.vb is a class containing a sub called UpdateDatabase that simply
calls a function in my DataAccess module:
-----------------------
Public Sub UpdateDatabase()
DataAccess.UploadTagsToDatabase(Me)
End Sub
-----------------------
If an exception is thrown in the DataAccess module I close all the
forms, or call Application.Exit. Either way, the forms all close but
the code returns to the calling sub in my Report.vb class. When it then
attempts to return to the code that instantiated the Report object and
called UpdateDatabase I get a null object exception because the form no
longer exists! Help, please, why did the application not die when I
told it to?
Thanks.
Pat Reddy
Industrial Controls Engineer
MAVERICK Technologies
VB.NET. When I close the application I loop through all open forms and
close them, like this basically
dim f as Form
for each f in forms
f.close()
Next
I heard this was better than using Application.Exit.
But, regardless of which I use, if I try to exit this way from a module,
like my DataAccess module upon an error connecting to a database for
example, all the forms close but the code that called the database
connection sub in my module continues to run. Here is some code...
Report.vb is a class containing a sub called UpdateDatabase that simply
calls a function in my DataAccess module:
-----------------------
Public Sub UpdateDatabase()
DataAccess.UploadTagsToDatabase(Me)
End Sub
-----------------------
If an exception is thrown in the DataAccess module I close all the
forms, or call Application.Exit. Either way, the forms all close but
the code returns to the calling sub in my Report.vb class. When it then
attempts to return to the code that instantiated the Report object and
called UpdateDatabase I get a null object exception because the form no
longer exists! Help, please, why did the application not die when I
told it to?
Thanks.
Pat Reddy
Industrial Controls Engineer
MAVERICK Technologies