473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

End all running code of .dll

Hi,

I'm writing a .dll. I'd like to know how to stop all the code running
from anywhere in the solution. For example:
-A class of the .dll is called from an .exe.
-Function A is called from the main sub.
-Function A calls Function B.
-Function B calls Function C.
-I need to terminate all the running code from Function C with a simple
method/function.

Is there an easy way to do this? Sometimes it gets very long to
propagate error handling back tho the main sub when deep into
functions.

I get this error when writing "End": 'End' statement cannot be used in
class library projects.

It seems 'End' statement doesn't work in .dlls...

Any ideas?

JakkyTchong

Aug 9 '06 #1
4 2991
Ja*********@yahoo.com wrote:
-A class of the .dll is called from an .exe.
-Function A is called from the main sub.
-Function A calls Function B.
-Function B calls Function C.
-I need to terminate all the running code from Function C with a simple
method/function.

Is there an easy way to do this? Sometimes it gets very long to
propagate error handling back tho the main sub when deep into
functions.
And that's what Exceptions are all about.

You'll probably need a flag defined at the class level that is read by
the lowest-level function.
When it sees this flag being set, the method throws an Exception.
The Exception is caught and handled by the top-level function, which
then decides what, if anything it can do about it.

Class Z
Private m_bOops As Boolean = False

Sub A()
Try
B()
Catch ex As Exception
Return ' or whatever
End Try
End Sub

Sub B()
C()
End Sub

Sub C()
Do While True
If m_bOops Then
Throw New ApplicationException( "Boom" )
End If
End Do
End Sub

End Class
It seems 'End' statement doesn't work in .dlls...
I would suggest that End is never required.

HTH,
Phill W.
Aug 9 '06 #2
Thanks Phill for the very useful snippet of code. That would work well
I think. Do yo know if it would be possible to do approximately the
same thing using events? I don't have any experience with events at
all. Would it be simple enough to implement?

JakkyTchong

Phill W. wrote:
Ja*********@yahoo.com wrote:
-A class of the .dll is called from an .exe.
-Function A is called from the main sub.
-Function A calls Function B.
-Function B calls Function C.
-I need to terminate all the running code from Function C with a simple
method/function.

Is there an easy way to do this? Sometimes it gets very long to
propagate error handling back tho the main sub when deep into
functions.

And that's what Exceptions are all about.

You'll probably need a flag defined at the class level that is read by
the lowest-level function.
When it sees this flag being set, the method throws an Exception.
The Exception is caught and handled by the top-level function, which
then decides what, if anything it can do about it.

Class Z
Private m_bOops As Boolean = False

Sub A()
Try
B()
Catch ex As Exception
Return ' or whatever
End Try
End Sub

Sub B()
C()
End Sub

Sub C()
Do While True
If m_bOops Then
Throw New ApplicationException( "Boom" )
End If
End Do
End Sub

End Class
It seems 'End' statement doesn't work in .dlls...

I would suggest that End is never required.

HTH,
Phill W.
Aug 10 '06 #3
Ja*********@yahoo.com wrote:
Do yo know if it would be possible to do approximately the
same thing using events? I don't have any experience with events at
all. Would it be simple enough to implement?
An event can spike a "notification" to some routine that is interested
in it, but can't affect the flow of execution - you can't get out of a
function by raising an event; you can by throwing an Exception.

HTH,
Phill W.
Aug 11 '06 #4
Alright then! An Exception it will be!

Thanks a lot Phill for your help and have a great weekend!

JakkyTchong
Phill W. wrote:
Ja*********@yahoo.com wrote:
Do yo know if it would be possible to do approximately the
same thing using events? I don't have any experience with events at
all. Would it be simple enough to implement?

An event can spike a "notification" to some routine that is interested
in it, but can't affect the flow of execution - you can't get out of a
function by raising an event; you can by throwing an Exception.

HTH,
Phill W.
Aug 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2294
by: Edg Bamyasi | last post by:
This Is A Late Cross Post from comp.lang.python. It seems the mistery is deeper then i expected. What is the running time of conactination on character strings. i.e. >> joe="123" >>...
4
10326
by: Bill Dika | last post by:
Hi I am trying to calculate a running total of a calculated textbox (tbAtStandard) in GroupFooter1 for placement in a textbox (tbTotalAtStandard) on my report in Groupfooter0. The problem...
9
3048
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
1
5992
by: Anonieko | last post by:
Query: How to display progress bar for long running page Answer: Yet another solution. REFERENCE: http://www.eggheadcafe.com/articles/20050108.asp My only regret is that when click the...
12
14498
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
9
3254
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
14
9586
by: Alex K. | last post by:
Hi all I'd like to avoid starting the same c# application twice on the same computer. How do I check if it is already running? Thank you
14
3417
by: fdu.xiaojf | last post by:
Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the...
1
6819
AHMEDYO
by: AHMEDYO | last post by:
Hi every one... This code simply show if your project running from VB6 IDE or running as single exe file, because visual basic 6.0 run your project within VB6.exe process and it doesn't create...
1
8116
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.