System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewStream C# (CSharp) Méthode

CreateViewStream() public méthode

public CreateViewStream ( ) : System.IO.MemoryMappedFiles.MemoryMappedViewStream
Résultat System.IO.MemoryMappedFiles.MemoryMappedViewStream
        public System.IO.MemoryMappedFiles.MemoryMappedViewStream CreateViewStream() { throw null; }
        public System.IO.MemoryMappedFiles.MemoryMappedViewStream CreateViewStream(long offset, long size) { throw null; }

Same methods

MemoryMappedFile::CreateViewStream ( long offset, long size ) : System.IO.MemoryMappedFiles.MemoryMappedViewStream
MemoryMappedFile::CreateViewStream ( long offset, long size, System access ) : System.IO.MemoryMappedFiles.MemoryMappedViewStream

Usage Example

        public Stream IncreaseSize(int value, out long offset)
        {
            lock (_lock)
            {
                while (Interlocked.Read(ref _counter) != 0)
                {
                    if (!Monitor.Wait(_lock, 10000, true))
                        throw new NotSupportedException();
                }

                FileStream file = new FileStream(_filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                try
                {
                    offset = MathEx.RoundUp(file.Length, 0x800);
                    file.SetLength(offset + value);
                    _mmf = MemoryMappedFile.CreateFromFile(file, null, 0, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.Inheritable, false);
                }
                catch
                {
                    file.SafeDispose();
                    throw;
                }

                Interlocked.Increment(ref _counter);
                DisposableStream result = new DisposableStream(_mmf.CreateViewStream(offset, value, MemoryMappedFileAccess.ReadWrite));
                result.AfterDispose.Add(new DisposableAction(Free));
                return result;
            }
        }
All Usage Examples Of System.IO.MemoryMappedFiles.MemoryMappedFile::CreateViewStream