Files
SharedMemoryExample/WriterApp/Program.cs
T
Matthias Heil a42b3393d4 Add typed shared-memory buffer example
Introduce a generic shared buffer with typed span access and
timeout-based read/write waits. Update the sample to verify data
shared between two buffer views.
2026-11-19 09:50:21 +01:00

19 lines
570 B
C#

using DotNext;
using System.Diagnostics;
Console.WriteLine("WriterApp.SharedBuffer:");
using var producer = new WriterApp.SharedBuffer<int>("MySharedBuffer", length: 10);
var intArray = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
producer.Write(intArray);
using var consumer = new WriterApp.SharedBuffer<int>("MySharedBuffer");
var intSpan = consumer.DataSpan;
for (var i = 0; i < intSpan.Length; i++)
{
Debug.Assert(intSpan[i] == intArray[i]);
}
Console.WriteLine("Start the second program, then press Enter here to close the array");
Console.ReadLine();