Files
SharedMemoryExample/WriterApp/Program.cs
T

19 lines
570 B
C#
Raw Normal View History

2026-11-19 09:50:21 +01:00
using DotNext;
using System.Diagnostics;
2026-11-18 11:20:38 +01:00
2026-11-19 09:50:21 +01:00
Console.WriteLine("WriterApp.SharedBuffer:");
using var producer = new WriterApp.SharedBuffer<int>("MySharedBuffer", length: 10);
2026-11-18 11:20:38 +01:00
2026-11-19 09:50:21 +01:00
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]);
}
2026-11-18 11:20:38 +01:00
Console.WriteLine("Start the second program, then press Enter here to close the array");
2026-11-19 09:50:21 +01:00
Console.ReadLine();