views:

27

answers:

1

I want to serialize an object(Form) to the MemoryStream and ulteriorly be able to deserialize it.

Is it possible to keep (read and write into) a global "memoryStreamContainer" when application is running?

A: 

Yes you can, but please note that the MemoryStream is not thread-safe, so you'll need to serialize access to it, for instance, by using the lock statement.

Could could even write some sort of tread-safe wrapper, that could use any type of Stream:

public sealed class ThreadSafeStreamWrapper
{
    private readonly Stream wrappedStream;
    public ThreadSafeStreamWrapper(Stream wrappedStream)
    {
        this.wrappedStream = wrappedStream;
    }

    // implementation
 }
Steven
I agree that my question should be "How can I" :)
serhio