Skip to content

About

Thread-safe spreadsheet system in C# and .NET with fine-grained locking, multithreading, a concurrent user simulator, and a Windows Forms interface.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Concurrent Spreadsheet System

A thread-safe spreadsheet system developed in C# and .NET, designed to support multiple users performing spreadsheet operations concurrently.

The project focuses on synchronization, fine-grained locking, safe concurrent access, and shared-memory programming.

Features

  • Thread-safe two-dimensional spreadsheet
  • Fine-grained locking with one ReaderWriterLockSlim per cell
  • Separate structure-level synchronization
  • Optional concurrent-search limiting with SemaphoreSlim
  • Concurrent read and write operations
  • Row and column exchange
  • Dynamic row and column insertion
  • Full-sheet and range-based searching
  • Find and replace operations
  • Save and load support
  • Multi-threaded user simulator
  • Windows Forms graphical interface

Project Structure

concurrent-spreadsheet-system/
├── Spreadsheet.Core/
│   ├── SharableSpreadSheet.cs
│   └── Spreadsheet.Core.csproj
│
├── Simulator/
│   ├── Program.cs
│   └── Simulator.csproj
│
├── SpreadsheetApp/
│   ├── Program.cs
│   ├── MainForm.cs
│   └── SpreadsheetApp.csproj
│
└── ConcurrentSpreadsheet.slnx

The solution contains three projects:

  • Spreadsheet.Core — shared thread-safe spreadsheet implementation.
  • Simulator — multi-threaded console simulation.
  • SpreadsheetApp — Windows Forms graphical application.

Spreadsheet.Core

The core module contains the SharableSpreadSheet implementation.

Each spreadsheet cell is protected by its own ReaderWriterLockSlim, allowing independent cells to be accessed concurrently.

A separate ReaderWriterLockSlim protects structural changes such as resizing or replacing the spreadsheet arrays.

An optional SemaphoreSlim limits the number of concurrent search operations.

Simulator

The simulator represents multiple users accessing the same spreadsheet concurrently.

Each user runs on a separate thread and performs randomized operations such as:

  • Reading and writing cells
  • Searching cells and ranges
  • Find and replace
  • Exchanging rows and columns
  • Adding rows and columns

SpreadsheetApp

A Windows Forms desktop application using DataGridView.

The interface supports:

  • Editing spreadsheet cells
  • Loading saved spreadsheets
  • Saving spreadsheets
  • Refreshing displayed data
  • Filling the spreadsheet with sample data

Technologies

  • C#
  • .NET 8
  • Windows Forms
  • Multithreading
  • ReaderWriterLockSlim
  • SemaphoreSlim

Build

dotnet build ConcurrentSpreadsheet.slnx

Run the Simulator

dotnet run --project Simulator/Simulator.csproj -- <rows> <cols> <threads> <operations> <sleep-ms>

Example:

dotnet run --project Simulator/Simulator.csproj -- 5 5 4 15 10

Run the GUI

The graphical application uses Windows Forms and is intended to run on Windows.

dotnet run --project SpreadsheetApp/SpreadsheetApp.csproj

Concurrency Design

                    SharableSpreadSheet
                           │
             ┌─────────────┴─────────────┐
             │                           │
      Structure Lock                Cell Locks
   ReaderWriterLockSlim      ReaderWriterLockSlim[,]
             │                           │
  rows / cols / arrays           Individual cells
             │
             └──── Optional SemaphoreSlim
                    for search limiting

The fine-grained synchronization design allows multiple threads to access independent cells concurrently while maintaining safe access during structural changes.

Author

Siraj Hoshan
Information Systems Engineering Student
Ben-Gurion University of the Negev

About

Thread-safe spreadsheet system in C# and .NET with fine-grained locking, multithreading, a concurrent user simulator, and a Windows Forms interface.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages