473,379 Members | 1,235 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Destroy on request

Hello everybody,
I've made a simple class that reads an xml-file with some methods to delete
a row, add a row and to get the amount of lines in the dataset:

public class bugreports
private dsbugreport as new dataset

public sub new()
dsbugreport.readxmlscheme(...)
dsbugreport.readxml(...)
end sub

public sub insertreport()
...
dsbugreport.tables(0).rows.add(...)
end sub

public function viewreports()
return dsbugreport
end function

protected overrides sub finalize()
dsbugreport.writexml(...)
end sub
end public class

My problem is that I need to call the finalize sub when I want it (most of
the times at the end of the sub that called my class) and not the garbage
collection. I tried setting the 'bugreports = nothing' but that didn't call
the finalize sub.
The only solution I can think of is putting the 'dsbugreport.writexml(...)'
line in every sub/function where I change something in the dataset, but is
this the best method?
Nov 20 '05 #1
3 1230
Why not set the reference to this to nothing, then GC.Collet()

OHM

ZippyV wrote:
Hello everybody,
I've made a simple class that reads an xml-file with some methods to
delete a row, add a row and to get the amount of lines in the dataset:

public class bugreports
private dsbugreport as new dataset

public sub new()
dsbugreport.readxmlscheme(...)
dsbugreport.readxml(...)
end sub

public sub insertreport()
...
dsbugreport.tables(0).rows.add(...)
end sub

public function viewreports()
return dsbugreport
end function

protected overrides sub finalize()
dsbugreport.writexml(...)
end sub
end public class

My problem is that I need to call the finalize sub when I want it
(most of the times at the end of the sub that called my class) and
not the garbage collection. I tried setting the 'bugreports =
nothing' but that didn't call the finalize sub.
The only solution I can think of is putting the
'dsbugreport.writexml(...)' line in every sub/function where I change
something in the dataset, but is this the best method?


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #2
GC.Collect()

OHM
One Handed Man wrote:
Why not set the reference to this to nothing, then GC.Collet()

OHM

ZippyV wrote:
Hello everybody,
I've made a simple class that reads an xml-file with some methods to
delete a row, add a row and to get the amount of lines in the
dataset:

public class bugreports
private dsbugreport as new dataset

public sub new()
dsbugreport.readxmlscheme(...)
dsbugreport.readxml(...)
end sub

public sub insertreport()
...
dsbugreport.tables(0).rows.add(...)
end sub

public function viewreports()
return dsbugreport
end function

protected overrides sub finalize()
dsbugreport.writexml(...)
end sub
end public class

My problem is that I need to call the finalize sub when I want it
(most of the times at the end of the sub that called my class) and
not the garbage collection. I tried setting the 'bugreports =
nothing' but that didn't call the finalize sub.
The only solution I can think of is putting the
'dsbugreport.writexml(...)' line in every sub/function where I change
something in the dataset, but is this the best method?


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #3
ZippyV,
The only solution I can think of is putting the 'dsbugreport.writexml(...)' line in every sub/function where I change something in the dataset, but is
this the best method? If you want to be certain that the file is always up to date, this would be
the "best" method!

An alternative would to be implement the Disposable/Finalization pattern
see:

http://msdn.microsoft.com/library/de...izeDispose.asp

Which then leaves it to the developer using your class to call Dispose when
they are done with the class.

I would be cautious about referring to the dsbugreport variable in the
Finalize method, as it may have been garbage collection already...

BTW: In your example I would consider having a Close method that Implements
IDisposable.Dispose, as that may be more "clear" to the developer using the
class:
public class bugreports Implements IDisposable

Public Sub Close() Implements IDisposable.Dispose
...
End Sub

End Class

Hope this helps
Jay

"ZippyV" <do**@mail.me> wrote in message
news:OG**************@tk2msftngp13.phx.gbl... Hello everybody,
I've made a simple class that reads an xml-file with some methods to delete a row, add a row and to get the amount of lines in the dataset:

public class bugreports
private dsbugreport as new dataset

public sub new()
dsbugreport.readxmlscheme(...)
dsbugreport.readxml(...)
end sub

public sub insertreport()
...
dsbugreport.tables(0).rows.add(...)
end sub

public function viewreports()
return dsbugreport
end function

protected overrides sub finalize()
dsbugreport.writexml(...)
end sub
end public class

My problem is that I need to call the finalize sub when I want it (most of
the times at the end of the sub that called my class) and not the garbage
collection. I tried setting the 'bugreports = nothing' but that didn't call the finalize sub.
The only solution I can think of is putting the 'dsbugreport.writexml(...)' line in every sub/function where I change something in the dataset, but is
this the best method?

Nov 20 '05 #4

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

Similar topics

0
by: Tuckbros | last post by:
Hi everybody, I am making a small site. This site uses sessions and I need to store pictures for each session. I solved this problem thanks to the session_set_save_handler() function. Sessions...
2
by: Rob | last post by:
My first GUI so be gentle... When I start my program I call a class that runs the initial window. While in this class if a certain button is pressed it calls a function outside the class. This...
6
by: max(01)* | last post by:
hi people. when i create a widget, such as a toplevel window, and then i destroy it, how can i test that it has been destroyed? the problem is that even after it has been destroyed, the instance...
8
by: vvenk | last post by:
Hello: I just wrote my first ASP.Net application. It worked fine on my machine and when I put into production, the ASP.Net process reaches 50% quite fast and then the system does not work...
2
by: Flavio | last post by:
Hi, I have a miniframe composed mainly of combo boxes, that I need to destroy and recreate multiple time with different choice lists for the combo boxes. My problem is that even after...
2
by: ShishKabab | last post by:
Hello Everyone, I have two functions: function purgeNode(node){ while(node.childNodes.length > 0){ var childNode = node.firstChild; if(childNode.childNodes.length > 0)...
6
by: muppetjones | last post by:
I'm pretty new at this, and I'm trying to figure out how Perl's classes work with signals. Specifically, it doesn't seem that a class's DESTROY function is called when you Ctrl-C the program. I...
4
by: Curious | last post by:
Hi, I have a timer object that's launched as below: mTimer = new System.Threading.Timer (new TimerCallBack(SubscribeTrade), null, 15000, 15000); void SubscribeTrade (object state) {...
3
by: drzoo2 | last post by:
Completely noob question as I am not a programmer but really trying hard to learn Python (Object oriented programming in general). I am writing a program in python that calls a popup window with...
6
by: itsraghz | last post by:
Dear All, I have an issue with destroy() method of java.lang.Process class. All what I am trying to do is, controlling the execution of one program through another. Let's say, Program B has to be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.