CSharpTest.Net
SharedMemoryStream Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SharedMemoryStream Class

Glossary Item Box

A memory stream that can be cloned to create an instance for another thread to access the same memory pool.

Syntax

Visual Basic (Declaration) 
Public Class SharedMemoryStream 
   Inherits SegmentedMemoryStream
   Implements CSharpTest.Net.Interfaces.IFactory(Of Stream) 
C# 
public class SharedMemoryStream : SegmentedMemoryStream, CSharpTest.Net.Interfaces.IFactory<Stream>  

Example

Library/Library.Test/TestStreamCache.cs

C#Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NETCopy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.IO.Stream
         CSharpTest.Net.IO.SegmentedMemoryStream
            CSharpTest.Net.IO.SharedMemoryStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys