Files

22 lines
586 B
C#
Raw Permalink 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");
2026-11-19 10:16:51 +01:00
consumer.BufferAction((span) =>
2026-11-19 09:50:21 +01:00
{
2026-11-19 10:16:51 +01:00
for (var i = 0; i < span.Length; i++)
{
Debug.Assert(span[i] == intArray[i]);
}
});
2026-11-19 09:50:21 +01:00
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();