From e4c11f2a8b5c3b78ec749ce429399cdee4afe8ba Mon Sep 17 00:00:00 2001 From: Felix Collins Date: Fri, 5 Sep 2025 09:38:19 +1200 Subject: [PATCH 1/3] Clarify thread safety in IoT libraries Added a section on thread safety for library objects. --- docs/iot/intro.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/iot/intro.md b/docs/iot/intro.md index 823f217c51572..dd1be2871a945 100644 --- a/docs/iot/intro.md +++ b/docs/iot/intro.md @@ -46,6 +46,9 @@ Some commonly used device bindings include: - [Max7219 - LED Matrix driver](https://github.com/dotnet/iot/tree/main/src/devices/Max7219) - [RGBLedMatrix - RGB LED Matrix](https://github.com/dotnet/iot/tree/main/src/devices/RGBLedMatrix) +## A word on threads +By convention objects in these libraries are **not** designed to be **thread safe**. This means that all access to an object should be done from the thread it was created on. Be aware when using the libraries that they may run other threads internally for monitoring hardware and firing events. If you subscribe to an event it will likely be fired from a different thread. + ## Supported operating systems `System.Device.Gpio` is supported on any operating system that supports .NET, including most versions of Linux that support ARM/ARM64 and Windows 10 IoT Core. From 4d09a0251ceb082081e3dced2148af2d90a41af1 Mon Sep 17 00:00:00 2001 From: Felix Collins Date: Mon, 8 Sep 2025 10:40:44 +1200 Subject: [PATCH 2/3] Update thread safety explanation in intro.md Rewrote to be more accurate and hopefully more readable. --- docs/iot/intro.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/iot/intro.md b/docs/iot/intro.md index dd1be2871a945..311b9ae96c9ca 100644 --- a/docs/iot/intro.md +++ b/docs/iot/intro.md @@ -47,7 +47,8 @@ Some commonly used device bindings include: - [RGBLedMatrix - RGB LED Matrix](https://github.com/dotnet/iot/tree/main/src/devices/RGBLedMatrix) ## A word on threads -By convention objects in these libraries are **not** designed to be **thread safe**. This means that all access to an object should be done from the thread it was created on. Be aware when using the libraries that they may run other threads internally for monitoring hardware and firing events. If you subscribe to an event it will likely be fired from a different thread. + +By default objects in these libraries are **not thread safe**. This means that access to an object must only be from one thread at a time. When using the libraries you must be aware that they will often run other threads internally for monitoring hardware and firing events. If you subscribe to an event, it will be fired from a different thread. It is your responsibility as a user of the library user to control thread access to the object. ## Supported operating systems From 9f77eb4523acfb05e71f7e98703776c68dde684b Mon Sep 17 00:00:00 2001 From: Felix Collins Date: Wed, 10 Sep 2025 11:50:57 +1200 Subject: [PATCH 3/3] Update docs/iot/intro.md Co-authored-by: Meaghan Osagie (Lewis) --- docs/iot/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/iot/intro.md b/docs/iot/intro.md index 311b9ae96c9ca..c9a9a029c8355 100644 --- a/docs/iot/intro.md +++ b/docs/iot/intro.md @@ -48,7 +48,7 @@ Some commonly used device bindings include: ## A word on threads -By default objects in these libraries are **not thread safe**. This means that access to an object must only be from one thread at a time. When using the libraries you must be aware that they will often run other threads internally for monitoring hardware and firing events. If you subscribe to an event, it will be fired from a different thread. It is your responsibility as a user of the library user to control thread access to the object. +By default, the objects in these libraries **aren't thread safe**. That means that access to an object must only be from one thread at a time. When using the libraries, you must be aware that they often run other threads internally for things like monitoring hardware and firing events. If you subscribe to an event, it's fired from a different thread. It's your responsibility to control thread access to the object. ## Supported operating systems