style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<chiefbraincloud> wrote in messageI
href="news:6079494@discussion.autodesk.com">news:6079494@discussion.autodesk.com...
use VB, so I translated it...
This line gave me a compile error
"ed.WriteMessage(bdId + nameOfBlock + " inserted");"
because operator +
is not defined for types ObjectId and String... but I get the feeling yours
didn't do that (c# maybe? seems odd)
Other than that, this code worked
in VB...with a different block name. I even made the block dynamic, and it
still worked.
You actually don't need the graphics flush either,
because the graphics will update when you close the object
anyway.
Are you sure there are visible entities in your
block?
You should do your Transaction and Try/Catch a little
differently, but it is not causing your problem.
the way you have your
try/catch and transaction, the trans will not get disposed if there is an
exception.
if you do it this way, it always gets disposed. (you'll have
to pardon me if I mess up on the syntax)
transaction tr =
db.TransactionManager.StartTransaction();
try
{
....
tr.commit();
}
catch
ex as
.....
{
msg
}
finally
{
tr.dispose
}
Inflation is really out of control!..
Normally you only get a penny for your thoughts;-)
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice neat
little package is good, his statement about "you will never want to use the
more confusing try/finally approach that 'chief' thinks is proper coding." is
not correct.
Try/Catch/Finally blocks are VERY helpful when
attempting to capture errors that will become fatal otherwise. In fact it is
best to use them ANY time the UI has a user control event. Then CATCH the
error and handle it, with a Finally that wraps up anything else that Using's
auto disposal is not appropriate for. Automatic disposal is not appropriate
for setting a variable back to another value (such as a boolean to ignore
events). Catch is also helpful for those random events such as inserting a
block from file when the file was renamed/moved/deleted.
So to
sum up, Using is great for items that MUST be disposed, Try/Catch/Finally is
great for trapping error prone areas of code.
That will be
$0.02 please.
jvj
No, I like Bar-B-Que...
Anyway, You just said the same thing I did in a different manner.
Using is good for disposing whether on purpose or by accident.
Try/Catch/Finally is good for error trapping and handling.
My original point was simply not to dismiss Try/Catch/Finally as a 'useless' programming feature.
Any Questions?
jvj
p.s. serve it fried on a stick, and I'll eat anything with bbq sauce.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in message
href="news:6080345@discussion.autodesk.com">news:6080345@discussion.autodesk.com...
No, I like Bar-B-Que...
Anyway, You
just said the same thing I did in a different manner.
Using is
good for disposing whether on purpose or by accident.
Try/Catch/Finally is good for error trapping and
handling.
My original point was simply not to dismiss
Try/Catch/Finally as a 'useless' programming feature.
Any
Questions?
jvj
p.s. serve it fried on a stick,
and I'll eat anything with bbq sauce.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally but
not to use it to dispose of objects that implement IDisposable.
Check out the link below for an interesting
read - Tony chimed in on the treads.
href="http://www.codeproject.com/KB/dotnet/idisposable.aspx">http://www.codeproject.com/KB/dotnet...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice neat
little package is good, his statement about "you will never want to use the
more confusing try/finally approach that 'chief' thinks is proper coding."
is not correct.
Try/Catch/Finally blocks are VERY helpful
when attempting to capture errors that will become fatal otherwise. In fact
it is best to use them ANY time the UI has a user control event. Then CATCH
the error and handle it, with a Finally that wraps up anything else that
Using's auto disposal is not appropriate for. Automatic disposal is not
appropriate for setting a variable back to another value (such as a boolean
to ignore events). Catch is also helpful for those random events such as
inserting a block from file when the file was
renamed/moved/deleted.
So to sum up, Using is great for items
that MUST be disposed, Try/Catch/Finally is great for trapping error prone
areas of code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object implements
IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally
but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want to
use the more confusing try/finally approach that 'chief' thinks is proper
coding." is not correct.
Try/Catch/Finally blocks are VERY
helpful when attempting to capture errors that will become fatal
otherwise. In fact it is best to use them ANY time the UI has a user
control event. Then CATCH the error and handle it, with a Finally that
wraps up anything else that Using's auto disposal is not appropriate for.
Automatic disposal is not appropriate for setting a variable back to
another value (such as a boolean to ignore events). Catch is also helpful
for those random events such as inserting a block from file when the file
was renamed/moved/deleted.
So to sum up, Using is great for
items that MUST be disposed, Try/Catch/Finally is great for trapping error
prone areas of code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080571@discussion.autodesk.com">news:6080571@discussion.autodesk.com...
One way is to chase its type by right clicking
the type and choosing 'go to definition'. This will display the metadata for
the
type. Now check what is inherits from. Repeat the
process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the way -
nice way to see what is going in there...
I think 'go to definition' in 05 opens the object
browser instead showing metadata. If so just check if the type has a
Dispose()
method.
The goal with using a using statement is to make
sure the unmanaged resource we are pointing to gets Disposed.
face=Arial size=2>We don't want
the object to go out of scope and possibly
get Garbaged Collected before the unmanaged
memory is released. This is a memory
leak in .net.
This same question came up on StackOverflow.com a
few weeks ago... Plow through here to find the answer.
href="http://stackoverflow.com/search?q=idisposable">http://stackoverflow.com/search?q=idisposabl...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object implements
IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally
but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want to
use the more confusing try/finally approach that 'chief' thinks is
proper coding." is not correct.
Try/Catch/Finally blocks
are VERY helpful when attempting to capture errors that will become
fatal otherwise. In fact it is best to use them ANY time the UI has a
user control event. Then CATCH the error and handle it, with a Finally
that wraps up anything else that Using's auto disposal is not
appropriate for. Automatic disposal is not appropriate for setting a
variable back to another value (such as a boolean to ignore events).
Catch is also helpful for those random events such as inserting a block
from file when the file was renamed/moved/deleted.
So to
sum up, Using is great for items that MUST be disposed,
Try/Catch/Finally is great for trapping error prone areas of
code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
One way is to chase its type by right clicking
the type and choosing 'go to definition'. This will display the metadata for
the
type. Now check what is inherits from. Repeat the
process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the way -
nice way to see what is going in there...
I think 'go to definition' in 05 opens the object
browser instead showing metadata. If so just check if the type has a
Dispose()
method.
The goal with using a using statement is to make
sure the unmanaged resource we are pointing to gets Disposed.
face=Arial size=2>We don't want
the object to go out of scope and possibly
get Garbaged Collected before the unmanaged
memory is released. This is a memory
leak in .net.
This same question came up on StackOverflow.com a
few weeks ago... Plow through here to find the answer.
href="http://stackoverflow.com/search?q=idisposable">http://stackoverflow.com/search?q=idisposabl...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object implements
IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally
but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want to
use the more confusing try/finally approach that 'chief' thinks is
proper coding." is not correct.
Try/Catch/Finally blocks
are VERY helpful when attempting to capture errors that will become
fatal otherwise. In fact it is best to use them ANY time the UI has a
user control event. Then CATCH the error and handle it, with a Finally
that wraps up anything else that Using's auto disposal is not
appropriate for. Automatic disposal is not appropriate for setting a
variable back to another value (such as a boolean to ignore events).
Catch is also helpful for those random events such as inserting a block
from file when the file was renamed/moved/deleted.
So to
sum up, Using is great for items that MUST be disposed,
Try/Catch/Finally is great for trapping error prone areas of
code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080593@discussion.autodesk.com">news:6080593@discussion.autodesk.com...
I appreciate your response. I have always been
curious because of folks in here promoting the use of the "using"
keyword.
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080571@discussion.autodesk.com">news:6080571@discussion.autodesk.com...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
One way is to chase its type by right clicking
the type and choosing 'go to definition'. This will display the metadata for
the
type. Now check what is inherits from. Repeat
the process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the way
- nice way to see what is going in there...
I think 'go to definition' in 05 opens the
object browser instead showing metadata. If so just check if the type has a
Dispose()
method.
The goal with using a using statement is to
make sure the unmanaged resource we are pointing to gets Disposed.
We don't want
the object to go out of scope and possibly
get Garbaged Collected before the unmanaged
memory is released. This is a memory
leak in .net.
This same question came up on StackOverflow.com
a few weeks ago... Plow through here to find the answer.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <
href="mailto:Beaver@yahoo.com">Beaver@yahoo.com> wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object
implements IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use
try/catch/finally but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want
to use the more confusing try/finally approach that 'chief' thinks is
proper coding." is not correct.
Try/Catch/Finally
blocks are VERY helpful when attempting to capture errors that will
become fatal otherwise. In fact it is best to use them ANY time the UI
has a user control event. Then CATCH the error and handle it, with a
Finally that wraps up anything else that Using's auto disposal is not
appropriate for. Automatic disposal is not appropriate for setting a
variable back to another value (such as a boolean to ignore events).
Catch is also helpful for those random events such as inserting a
block from file when the file was
renamed/moved/deleted.
So to sum up, Using is great for
items that MUST be disposed, Try/Catch/Finally is great for trapping
error prone areas of code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080610@discussion.autodesk.com">news:6080610@discussion.autodesk.com...
Your welcome... A nice key-binding to get you
back to where you started when using 'go to definition' is
'ctrl+shift+f12'.
This will bring you back to where you started no
matter how deep you chase the type with 'go to definition'.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080593@discussion.autodesk.com">news:6080593@discussion.autodesk.com...
I appreciate your response. I have always been
curious because of folks in here promoting the use of the "using"
keyword.
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080571@discussion.autodesk.com">news:6080571@discussion.autodesk.com...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
One way is to chase its type by right
clicking the type and choosing 'go to definition'. This will display the
metadata for the
type. Now check what is inherits from. Repeat
the process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the
way - nice way to see what is going in there...
I think 'go to definition' in 05 opens the
object browser instead showing metadata. If so just check if the type has
a Dispose()
method.
The goal with using a using statement is to
make sure the unmanaged resource we are pointing to gets Disposed.
We don't want
the object to go out of scope and
possibly get Garbaged Collected before the
unmanaged memory is released. This is a memory
leak in .net.
This same question came up on
StackOverflow.com a few weeks ago... Plow through here to find the
answer.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <
href="mailto:Beaver@yahoo.com">Beaver@yahoo.com> wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object
implements IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in
message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use
try/catch/finally but not to use it to dispose of objects that
implement IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a
nice neat little package is good, his statement about "you will
never want to use the more confusing try/finally approach that
'chief' thinks is proper coding." is not
correct.
Try/Catch/Finally blocks are VERY helpful
when attempting to capture errors that will become fatal otherwise.
In fact it is best to use them ANY time the UI has a user control
event. Then CATCH the error and handle it, with a Finally that wraps
up anything else that Using's auto disposal is not appropriate for.
Automatic disposal is not appropriate for setting a variable back to
another value (such as a boolean to ignore events). Catch is also
helpful for those random events such as inserting a block from file
when the file was renamed/moved/deleted.
So to sum
up, Using is great for items that MUST be disposed,
Try/Catch/Finally is great for trapping error prone areas of
code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080610@discussion.autodesk.com">news:6080610@discussion.autodesk.com...
Your welcome... A nice key-binding to get you
back to where you started when using 'go to definition' is
'ctrl+shift+f12'.
This will bring you back to where you started no
matter how deep you chase the type with 'go to definition'.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080593@discussion.autodesk.com">news:6080593@discussion.autodesk.com...
I appreciate your response. I have always been
curious because of folks in here promoting the use of the "using"
keyword.
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080571@discussion.autodesk.com">news:6080571@discussion.autodesk.com...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
One way is to chase its type by right
clicking the type and choosing 'go to definition'. This will display the
metadata for the
type. Now check what is inherits from. Repeat
the process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the
way - nice way to see what is going in there...
I think 'go to definition' in 05 opens the
object browser instead showing metadata. If so just check if the type has
a Dispose()
method.
The goal with using a using statement is to
make sure the unmanaged resource we are pointing to gets Disposed.
We don't want
the object to go out of scope and
possibly get Garbaged Collected before the
unmanaged memory is released. This is a memory
leak in .net.
This same question came up on
StackOverflow.com a few weeks ago... Plow through here to find the
answer.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <
href="mailto:Beaver@yahoo.com">Beaver@yahoo.com> wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object
implements IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in
message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use
try/catch/finally but not to use it to dispose of objects that
implement IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a
nice neat little package is good, his statement about "you will
never want to use the more confusing try/finally approach that
'chief' thinks is proper coding." is not
correct.
Try/Catch/Finally blocks are VERY helpful
when attempting to capture errors that will become fatal otherwise.
In fact it is best to use them ANY time the UI has a user control
event. Then CATCH the error and handle it, with a Finally that wraps
up anything else that Using's auto disposal is not appropriate for.
Automatic disposal is not appropriate for setting a variable back to
another value (such as a boolean to ignore events). Catch is also
helpful for those random events such as inserting a block from file
when the file was renamed/moved/deleted.
So to sum
up, Using is great for items that MUST be disposed,
Try/Catch/Finally is great for trapping error prone areas of
code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object implements
IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally
but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want to
use the more confusing try/finally approach that 'chief' thinks is proper
coding." is not correct.
Try/Catch/Finally blocks are VERY
helpful when attempting to capture errors that will become fatal
otherwise. In fact it is best to use them ANY time the UI has a user
control event. Then CATCH the error and handle it, with a Finally that
wraps up anything else that Using's auto disposal is not appropriate for.
Automatic disposal is not appropriate for setting a variable back to
another value (such as a boolean to ignore events). Catch is also helpful
for those random events such as inserting a block from file when the file
was renamed/moved/deleted.
So to sum up, Using is great for
items that MUST be disposed, Try/Catch/Finally is great for trapping error
prone areas of code.
That will be $0.02
please.
jvj
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080571@discussion.autodesk.com">news:6080571@discussion.autodesk.com...
One way is to chase its type by right clicking
the type and choosing 'go to definition'. This will display the metadata for
the
type. Now check what is inherits from. Repeat the
process for the types in inherits from until you come to an end or
find
IDisposable. Open all comments up along the way -
nice way to see what is going in there...
I think 'go to definition' in 05 opens the object
browser instead showing metadata. If so just check if the type has a
Dispose()
method.
The goal with using a using statement is to make
sure the unmanaged resource we are pointing to gets Disposed.
face=Arial size=2>We don't want
the object to go out of scope and possibly
get Garbaged Collected before the unmanaged
memory is released. This is a memory
leak in .net.
This same question came up on StackOverflow.com a
few weeks ago... Plow through here to find the answer.
href="http://stackoverflow.com/search?q=idisposable">http://stackoverflow.com/search?q=idisposabl...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Beaver" <Beaver@yahoo.com>
wrote in message
href="news:6080495@discussion.autodesk.com">news:6080495@discussion.autodesk.com...
How does one know whether an object implements
IDisposable?
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6080266@discussion.autodesk.com">news:6080266@discussion.autodesk.com...
He wasn't saying not to use try/catch/finally
but not to use it to dispose of objects that implement
IDisposable.
Check out the link below for an
interesting read - Tony chimed in on the
treads.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<JamieVJohnson> wrote in messageWhile
href="news:6080237@discussion.autodesk.com">news:6080237@discussion.autodesk.com...
Tony states that Using is great for wrapping up Transactions in a nice
neat little package is good, his statement about "you will never want to
use the more confusing try/finally approach that 'chief' thinks is
proper coding." is not correct.
Try/Catch/Finally blocks
are VERY helpful when attempting to capture errors that will become
fatal otherwise. In fact it is best to use them ANY time the UI has a
user control event. Then CATCH the error and handle it, with a Finally
that wraps up anything else that Using's auto disposal is not
appropriate for. Automatic disposal is not appropriate for setting a
variable back to another value (such as a boolean to ignore events).
Catch is also helpful for those random events such as inserting a block
from file when the file was renamed/moved/deleted.
So to
sum up, Using is great for items that MUST be disposed,
Try/Catch/Finally is great for trapping error prone areas of
code.
That will be $0.02
please.
jvj