473,796 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2290
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.co m

"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.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.c om> wrote in
message news:OT******** ******@TK2MSFTN GP11.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.co m

"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.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.r illing.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.co m>
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
2532
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 constructors class MyClass { Foo foo; // foo and bar require default constructors Bar bar; public:
2
13562
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? TIA, ves
0
1822
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' property has been changed and the ListBox should be updated to reflect the new name? Thanks! -Noah Coad Microsoft MVP & MCP
2
3433
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 BinaryReader(fs); BinaryWriter bw = new BinaryWriter(fs); /* BinaryWriter writes, flushes, etc */ /* BinaryReader seeks, reads, etc */
4
26809
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 of System.IO.StringWriter (or, what is its added value)??? It can do the same things with StringBuilder, and I see no added value. The reason why I need the string stream, is that I have a library that knows
4
2568
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 than polling the database for changes all the time. My initial problem is that I need to create a static list so that it can be dynamically looked at by other assemblies, but SQL Server won't allow me to attach a dll which contains a static...
7
5218
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 MemoryStream in case I wish to reload information from the MemoryStream using BinaryReader. Thanks
7
5113
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 loop (to get a 'multiple cat'-like behavior) and the second time around it returns an empty string instead of waiting for more input. This makes me think that either the end-of-stream stays in the buffer or cin or its buffer is in some bad
0
9535
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,...
0
10242
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
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 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...
1
7558
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 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...
0
6800
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();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
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 we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.