473,396 Members | 1,929 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,396 software developers and data experts.

Can a Stream notify other objects when it has been changed?

Is there anyway of being notified when a Stream is modified? Basically, If
one of my objects is passed a stream, I would like to initialize an object
cache. Then when the Stream changes, I would like to update the cache.
Does not look like the stream has any event that I can hook.
Nov 15 '05 #1
3 2267
Peter,

No, there is no way to do this, and if there was, then I would be
worried. Not all streams support seeking on the stream, so for something
like a network connection, this would be a problem.

What you want to really do, IMO, is to find out if the store that the
stream represents (db, network, file, etc, etc) has changed, and if it has,
get a new stream.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is there anyway of being notified when a Stream is modified? Basically, If one of my objects is passed a stream, I would like to initialize an object
cache. Then when the Stream changes, I would like to update the cache.
Does not look like the stream has any event that I can hook.

Nov 15 '05 #2
How can I determing if the stream has changed? Is some other object changes
a byte in the middle of the stream, how can I be notified of this?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OT**************@TK2MSFTNGP11.phx.gbl...
Peter,

No, there is no way to do this, and if there was, then I would be
worried. Not all streams support seeking on the stream, so for something
like a network connection, this would be a problem.

What you want to really do, IMO, is to find out if the store that the
stream represents (db, network, file, etc, etc) has changed, and if it has, get a new stream.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is there anyway of being notified when a Stream is modified? Basically,

If
one of my objects is passed a stream, I would like to initialize an object cache. Then when the Stream changes, I would like to update the cache.
Does not look like the stream has any event that I can hook.


Nov 15 '05 #3
Peter Rilling <pe***@nospam.rilling.net> wrote:
How can I determing if the stream has changed? Is some other object changes
a byte in the middle of the stream, how can I be notified of this?


You could wrap the existing stream in your own stream, which forwards
on all methods to the other stream, but raises an event every time a
write occurs.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4

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

Similar topics

21
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default...
2
by: Vespasian | last post by:
notify() and wait() throw an exception if the calling thread does not own the object's monitor. Does this imply that the check is made at runtime, and if so, why can't it be made at compile time? ...
0
by: Noah Coad [MVP .NET/C#] | last post by:
I have an array of Client objects that I'm binding to a ListBox. The DisplayMember property of the ListBox is set to "Name" (the name of the client). How do I notify the ListBox that the 'Name'...
2
by: Daniel Goldman | last post by:
Hi, Any advice about both a BinaryReader and BinaryWriter containing same FileStream at same time? Like: Stream fs = new FileStream("output.dbf", FileMode.Create); BinaryReader br = new...
4
by: TT (Tom Tempelaere) | last post by:
Hey there, I need a string stream, but I can't find one in .NET. I thought StringWriter would derive from Stream, alas it doesn't do so. Which leads me to my next question: What is the purpose...
4
by: simo | last post by:
I have a requirement to create a sorted list of objects, stored within an assembly, and I would like to use a After Insert/Update trigger to notify that assembly that something has changed, rather...
7
by: Peter Morris | last post by:
Can I use a BinaryWriter without it closing the underlying stream? I want to save information to a MemoryStream using a BinaryWriter but I want to dispose of the BinaryWriter and keep the...
7
by: Sanyi | last post by:
What is cin's streambuffer's state and content after the following (using namespace std)? string((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()) ); I am trying to use this in a...
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
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
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
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...
0
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
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,...

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.