From b08fbe13eea34b46975f67ba1db6dacd76d0a7f2 Mon Sep 17 00:00:00 2001 From: Matthias Heil Date: Wed, 18 Nov 2026 11:20:38 +0100 Subject: [PATCH] Initial commit --- .gitignore | 5 +++++ ReaderApp/Program.cs | 13 +++++++++++++ ReaderApp/ReaderApp.csproj | 14 ++++++++++++++ SharedMemoryExample.slnx | 4 ++++ WriterApp/Program.cs | 8 ++++++++ WriterApp/WriterApp.csproj | 14 ++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 .gitignore create mode 100644 ReaderApp/Program.cs create mode 100644 ReaderApp/ReaderApp.csproj create mode 100644 SharedMemoryExample.slnx create mode 100644 WriterApp/Program.cs create mode 100644 WriterApp/WriterApp.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e915029 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs diff --git a/ReaderApp/Program.cs b/ReaderApp/Program.cs new file mode 100644 index 0000000..b352f2d --- /dev/null +++ b/ReaderApp/Program.cs @@ -0,0 +1,13 @@ +using SharedMemory; + +try +{ + using var numbers = new SharedArray("MySharedArray"); + Console.WriteLine(numbers.Length); + Console.WriteLine(numbers[0]); + Console.WriteLine(numbers[^1]); +} +catch (FileNotFoundException) +{ + Console.WriteLine("No process has MySharedArray open. Start the first program before this one."); +} \ No newline at end of file diff --git a/ReaderApp/ReaderApp.csproj b/ReaderApp/ReaderApp.csproj new file mode 100644 index 0000000..1748380 --- /dev/null +++ b/ReaderApp/ReaderApp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + diff --git a/SharedMemoryExample.slnx b/SharedMemoryExample.slnx new file mode 100644 index 0000000..5623c16 --- /dev/null +++ b/SharedMemoryExample.slnx @@ -0,0 +1,4 @@ + + + + diff --git a/WriterApp/Program.cs b/WriterApp/Program.cs new file mode 100644 index 0000000..5c3c63a --- /dev/null +++ b/WriterApp/Program.cs @@ -0,0 +1,8 @@ +using SharedMemory; + +using var numbers = new SharedArray("MySharedArray", length: 10); +numbers[0] = 123; +numbers[^1] = 456; + +Console.WriteLine("Start the second program, then press Enter here to close the array"); +Console.ReadLine(); \ No newline at end of file diff --git a/WriterApp/WriterApp.csproj b/WriterApp/WriterApp.csproj new file mode 100644 index 0000000..1748380 --- /dev/null +++ b/WriterApp/WriterApp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net10.0 + enable + enable + + + + + + +