473,473 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Object Lifetime

I have a static object that gets referenced at application startup. This
object stores a dataset and various strings to be used whenever required.
This object may be called at anytime to provide the data and strings, but can
be waiting for any length of time period i.e 24hours (this is not a webapp,
but a kiosk winform). 99% of the time, the object is available and when
required provides its information. the 1% of the time, I get a null
reference exeception. Is there any method that will guarantee that the
object will be available for the lifetime of the application?
Any help will be of assistance, thank you
Richard

Nov 16 '05 #1
6 1489
Hi Richard
If you are going to keep this variable for such very long time ( more than
a day ) . Instead of overloading the memory all the time , why don't you
use serializer to serialize it into file and you can desterilize it back
when needed
http://msdn.microsoft.com/library/de...us/dnexxml/htm
l/xml01202003.asp
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
ok, hadnt thought of that, the reason i have these objects is to store a
dataset in memory (a bit like a cache), that way the database can go offline
(it could be on a different pc) or if the network fails, the kiosk will still
work. Is there a good method to serialize and deserialize all the data
quickly?

"Mohamoss" wrote:
Hi Richard
If you are going to keep this variable for such very long time ( more than
a day ) . Instead of overloading the memory all the time , why don't you
use serializer to serialize it into file and you can desterilize it back
when needed
http://msdn.microsoft.com/library/de...us/dnexxml/htm
l/xml01202003.asp
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
Hi,

It should be available all the time, at least as long as the appdomain is
active, maybe you get this errors at the start of the application, when the
data is being loaded.

if not give more details of the app. itself

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Richard Steele" <Ri***********@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
I have a static object that gets referenced at application startup. This
object stores a dataset and various strings to be used whenever required.
This object may be called at anytime to provide the data and strings, but
can
be waiting for any length of time period i.e 24hours (this is not a
webapp,
but a kiosk winform). 99% of the time, the object is available and when
required provides its information. the 1% of the time, I get a null
reference exeception. Is there any method that will guarantee that the
object will be available for the lifetime of the application?
Any help will be of assistance, thank you
Richard

Nov 16 '05 #4
Ignacio

when the app loads up, all the data is cached into data sets for the life of
the app (or whenever a data refresh is required), each class has its own
dataset and is called upon when required. I have 3 objects (using the same
class) that provide formatted data for 3 functions 1 in particular being a
data driven screen saver. When the app boots,it checks for data issues and
reports accordingly. During the day, the user can update their data using my
own publisher methodology . This effectively disposes all the objects and
rebuilds them using the same method as when the app boots. I am 99.9%
guarenteed that the data is correct, when the app boots and on refresh. The
issue is, when the screen saver has been working for i.e. 12 hours non stop,
the kiosk may want to be used, therefore by a customer pressing a button, the
app comes out of the screen saver mode and goes into search for items mode
(it actually uses an embedded ie browser to show HTML). Last night the app
having been in screen saver mode for 3 hours, was used and a null reference
exception (that was handled) was thrown. is there anyway I can periodically
refresh my objects that are not being used until required, without having to
reresh the whole lot. Thanks very much for your help, hope you understand
what is happening
Richard
"Richard Steele" wrote:
ok, hadnt thought of that, the reason i have these objects is to store a
dataset in memory (a bit like a cache), that way the database can go offline
(it could be on a different pc) or if the network fails, the kiosk will still
work. Is there a good method to serialize and deserialize all the data
quickly?

"Mohamoss" wrote:
Hi Richard
If you are going to keep this variable for such very long time ( more than
a day ) . Instead of overloading the memory all the time , why don't you
use serializer to serialize it into file and you can desterilize it back
when needed
http://msdn.microsoft.com/library/de...us/dnexxml/htm
l/xml01202003.asp
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #5
Ignacio

when the app loads up, all the data is cached into data sets for the life of
the app (or whenever a data refresh is required), each class has its own
dataset and is called upon when required. I have 3 objects (using the same
class) that provide formatted data for 3 functions 1 in particular being a
data driven screen saver. When the app boots,it checks for data issues and
reports accordingly. During the day, the user can update their data using my
own publisher methodology . This effectively disposes all the objects and
rebuilds them using the same method as when the app boots. I am 99.9%
guarenteed that the data is correct, when the app boots and on refresh. The
issue is, when the screen saver has been working for i.e. 12 hours non stop,
the kiosk may want to be used, therefore by a customer pressing a button, the
app comes out of the screen saver mode and goes into search for items mode
(it actually uses an embedded ie browser to show HTML). Last night the app
having been in screen saver mode for 3 hours, was used and a null reference
exception (that was handled) was thrown. is there anyway I can periodically
refresh my objects that are not being used until required, without having to
reresh the whole lot. Thanks very much for your help, hope you understand
what is happening
Richard
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

It should be available all the time, at least as long as the appdomain is
active, maybe you get this errors at the start of the application, when the
data is being loaded.

if not give more details of the app. itself

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Richard Steele" <Ri***********@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
I have a static object that gets referenced at application startup. This
object stores a dataset and various strings to be used whenever required.
This object may be called at anytime to provide the data and strings, but
can
be waiting for any length of time period i.e 24hours (this is not a
webapp,
but a kiosk winform). 99% of the time, the object is available and when
required provides its information. the 1% of the time, I get a null
reference exeception. Is there any method that will guarantee that the
object will be available for the lifetime of the application?
Any help will be of assistance, thank you
Richard


Nov 16 '05 #6
Hi Richard
in that case of structured data( specially dataset ) best is to use XML
serializer . but since what you are saving is really a dataset it could me
much simpler and more effictive if you just use the WriteXML and ReadXml
Methods of the dataset . you what you would so is simply as follows

MyDataSet.WriteXml("tempFile"); \\ to save your data
\\ then when you want it back just read it from that temp file
MyNewDataSet..ReadXml("tempFile");
You might want to use InfroceSchema as the write mode if you want to keep
data constrains and table relations as well.

Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #7

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

Similar topics

4
by: johny smith | last post by:
Suppose there is a policy that all objects are statically declared. For example: static Car car(); Then, is there a reason to have a destructor defined for the class Car. It would seem...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
8
by: pt | last post by:
Hallo, i wonder how it is going to be of this code below regarding of the return of temporary object. Prototypes: =========== bool Activation(TCHAR *c); std::basic_string<TCHAR> GetFile();
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
16
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
3
by: nagashre | last post by:
class A { public: A():a(0), b(0){} handleMyMsg( char* aa, char*bb); private: processMessage();
6
by: better_cs_now | last post by:
Hello all, class Foo {/* Details don't matter */}; class Bar { public: Bar(): m_Foo(/* Construct a Foo however it wants to be constructed */); const Foo &GetFoo() const { return m_Foo; }...
6
by: Rajesh | last post by:
I read Global Object's constructor will be called before main() function; In which situation it can be really helpful? Is it good practice use Global object and its constructor ? Thanks,...
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...
1
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
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
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
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
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.