G'Day,
I have a simple peice of code behaving in a rather eratic manner.
outputStreams[(int)service] = new MemoryStream();
//.... some code to add values to the stream ...
bool ready = false;
//.... some code...
ready = (outputStreams[(int)service].Length > 0);
The last line of code is giving me extrodanary grivance so I put a
breakpoint on it.
When inspected at this breakpoint "outputStreams[(int)service].Length"
equates to 45.
Yet after the statement completes "ready" remains false.
"outputStreams" does not have anything else using it's name in a
different scope so the watch is definatly inspecting the variable in
the statement.
"ready" does not have anything else using it's name in a different
scope so the assignment is definatly inspecting the variable in the
statement. Yes ready is a local variable.
I can only think of two unlikely scenarios to explain this problem I am
facing.
1) The ">" operator does not like to compare a long value with the
expession "0".
2) The watch is given a eronious value when it reads the poperty
outputStreams[(int)service].Length and the code revices a another value
when calling the property.
Well if either of those two possibilites were true id be rather
suprissed.
Anyway for the paraniod I include a dump of the watch in question.
I just find this particular problem so bizzare I thought I'd share it.
-dm
- outputStreams[(int)service] {System.IO.MemoryStream} System.IO.MemoryStream
- System.IO.Stream {System.IO.MemoryStream} System.IO.Stream
+ System.MarshalByRefObject {System.IO.MemoryStream} System.MarshalByRefObject
CanRead true bool
CanSeek true bool
CanWrite true bool
Length 45 long
+ Null {System.IO.Stream.NullStream} System.IO.Stream
Position 45 long
+ _buffer {Length=256} byte[]
_capacity 256 int
_expandable true bool
_exposable true bool
_isOpen true bool
_length 45 int
_origin 0 int
_position 45 int
_writable true bool
CanRead true bool
CanSeek true bool
CanWrite true bool
Capacity 256 int
Length 45 long
MemStreamMaxLength 2147483647 int
Position 45 long