Use `SharedBuffer<int>` across the reader and writer apps, with callback-based buffer access. Add bounds checks to array and span read/write operations.
16 lines
412 B
C#
16 lines
412 B
C#
|
|
try
|
|
{
|
|
using var consumer = new WriterApp.SharedBuffer<int>("MySharedBuffer");
|
|
consumer.BufferAction((span) =>
|
|
{
|
|
for (var i = 0; i < span.Length; i++)
|
|
{
|
|
Console.WriteLine($"Read {span[i]} from the shared buffer");
|
|
}
|
|
});
|
|
}
|
|
catch (FileNotFoundException)
|
|
{
|
|
Console.WriteLine("No process has MySharedArray open. Start the first program before this one.");
|
|
} |