I have a user control which creates an Excel spread sheet and badly needs
Dispose/Finalize. I've read up on the subject in Balena and I think I
understand what is going on. But the VS generated coded confuses me a bit.
VS generates a Dispose subroutine, but it's not obvious if it is ok to
modify it. In the New subroutine VS makes clear that you can add code to it
and tell you where to add it ("Add any initialization after the
InitializeCompo nent() call"). But there is no such direction in the
generated Dispose subroutine.
VS does not generate a Finalize subroutine. That confuses me. Shouldn't
all controls have a Finalize method. If I code a Finalize method (which I
should, right?) then I should also create a static "disposed"varia ble,
right? That seems like the thing to do but on the other hand VS did not
generate one.
I'll be grateful if you can help me with these areas of confusion.
Bob 2 1296
Well i believe that Francesco is pretty clear in how and when to use
Dispose/Finalize
"the Dispose/Finalize pattern should be used only when your type invokes
unmanaged code that allocates unmanaged resources (including unmanaged
memory)"
and for detailed info see this article ( where he explains a simplified
aproach with some usefull links to detailed information ) http://www.dotnet2themax.com/blogs/f...c3c219c78.aspx
regards
Michel Posseth [MCP]
"eBob.com" wrote:
I have a user control which creates an Excel spread sheet and badly needs
Dispose/Finalize. I've read up on the subject in Balena and I think I
understand what is going on. But the VS generated coded confuses me a bit.
VS generates a Dispose subroutine, but it's not obvious if it is ok to
modify it. In the New subroutine VS makes clear that you can add code to it
and tell you where to add it ("Add any initialization after the
InitializeCompo nent() call"). But there is no such direction in the
generated Dispose subroutine.
VS does not generate a Finalize subroutine. That confuses me. Shouldn't
all controls have a Finalize method. If I code a Finalize method (which I
should, right?) then I should also create a static "disposed"varia ble,
right? That seems like the thing to do but on the other hand VS did not
generate one.
I'll be grateful if you can help me with these areas of confusion.
Bob
eBob,
One of the goals in Net languages is to manage the finalize for you. One of
the main reasons why it is called "Managed code". (This not for C++ MFC).
I hope this helps,
Cor
"eBob.com" <eB******@total lybogus.comschr eef in bericht
news:u5******** *****@TK2MSFTNG P03.phx.gbl...
>I have a user control which creates an Excel spread sheet and badly needs Dispose/Finalize. I've read up on the subject in Balena and I think I understand what is going on. But the VS generated coded confuses me a bit.
VS generates a Dispose subroutine, but it's not obvious if it is ok to
modify it. In the New subroutine VS makes clear that you can add code to
it and tell you where to add it ("Add any initialization after the
InitializeCompo nent() call"). But there is no such direction in the
generated Dispose subroutine.
VS does not generate a Finalize subroutine. That confuses me. Shouldn't
all controls have a Finalize method. If I code a Finalize method (which I
should, right?) then I should also create a static "disposed"varia ble,
right? That seems like the thing to do but on the other hand VS did not
generate one.
I'll be grateful if you can help me with these areas of confusion.
Bob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RiteshDotNet |
last post by:
..net Frame work
1. Dispose Method what it does ?
A. who its call / when it calls ?
B. Is it fire automatically ?
c. When dispose method is call what it does ?
D. Release a Object from memory or release refrence from memory ?
E. If it release object from memory then what GC does ?
2. Which class can have dispose method ?
class which is member of IDispose Inteface
3. Where we should use abstract / Interface ?
|
by: Joe Abou Jaoude |
last post by:
I m preparing to pass the 70-306 exam, so i downloaded Q & A
from multiple sites.
There's this question that really confuses me, coz i see that both
answers A and C are both correct.
Can anyone help me to pick the right answer and explain me why ?
thx.
Your development team creates an order entry application by using
Visual Studio .NET. The application stores and retrieves data in a
|
by: Dennis |
last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose
method based on advice from this newsgroup. However, I'm not sure how to
dispose of the following object that was created inside a method call.
dim myvar as new object1
object1.dosomethingmethod(new object2)
Note that object 2 has a dispose method but how do I dispose of it unless I
do the following:
|
by: RiteshDotNet |
last post by:
..net Frame work
1. Dispose Method what it does ?
A. who its call / when it calls ?
B. Is it fire automatically ?
c. When dispose method is call what it does ?
D. Release a Object from memory or release refrence from memory ?
E. If it release object from memory then what GC does ?
2. Which class can have dispose method ?
class which is member of IDispose Inteface
3. Where we should use abstract / Interface ?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |