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?
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?
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
}