ThunderDesign.Net-PCL.Threading
2.0.1
dotnet add package ThunderDesign.Net-PCL.Threading --version 2.0.1
NuGet\Install-Package ThunderDesign.Net-PCL.Threading -Version 2.0.1
<PackageReference Include="ThunderDesign.Net-PCL.Threading" Version="2.0.1" />
<PackageVersion Include="ThunderDesign.Net-PCL.Threading" Version="2.0.1" />
<PackageReference Include="ThunderDesign.Net-PCL.Threading" />
paket add ThunderDesign.Net-PCL.Threading --version 2.0.1
#r "nuget: ThunderDesign.Net-PCL.Threading, 2.0.1"
#addin nuget:?package=ThunderDesign.Net-PCL.Threading&version=2.0.1
#tool nuget:?package=ThunderDesign.Net-PCL.Threading&version=2.0.1
ThunderDesign.Net-PCL.Threading
A combination of generic Thread-Safe objects for .Net development.
🚀 Now with .NET 8 support and built-in Source Generators! 🚀
- .NET 8: Take advantage of the latest .NET features and performance improvements.
- Source Generators: Eliminate boilerplate and let the library generate thread-safe, bindable properties for you automatically!
Get started faster, write less code, and enjoy modern .NET development!
A simple C# repository containing a few basic useful Thread-Safe Objects.
Highlights include:
- Collections
- CollectionThreadSafe
- DictionaryThreadSafe
- HashSetThreadSafe
- LinkedListThreadSafe
- ListThreadSafe
- ObservableCollectionThreadSafe
- ObservableDictionaryThreadSafe
- QueueThreadSafe
- SortedDictionaryThreadSafe
- SortedListThreadSafe
- StackThreadSafe
- DataCollections
- ObservableDataCollection
- ObservableDataDictionary
- DataObjects
- BindableDataObject
- DataObject
- Extentions
- IBindableObjectExtention
- INotifyCollectionChangedExtension
- INotifyPropertyChangedExtension
- ObjectExtention
- HelperClasses
- ThreadHelper
- Interfaces
- IBindableCollection
- IBindableDataObject
- IBindableDataObject<Key>
- IBindableObject
- ICollectionThreadSafe
- IDataObject
- IDataObject<Key>
- IDictionaryThreadSafe
- IHashSetThreadSafe
- ILinkedListThreadSafe
- IListThreadSafe
- IObservableDataCollection
- IObservableDataCollection<T>
- ISortedDictionaryThreadSafe
- IStackThreadSafe
- Objects
- BindableObject
- ThreadObject
Source Generators
The ThunderDesign.Net-PCL.Threading
project provides Roslyn-based source generators that automate the creation of common boilerplate code for thread-safe and bindable objects in this library. By including this package in your project, you can reduce repetitive code and ensure consistency across your data and collection classes.
What does it do?
- Automatic Property Generation:
The source generator scans your code for fields marked with specific attributes (such as[BindableProperty]
or[Property]
) and automatically generates the corresponding properties, including thread-safe accessors andINotifyPropertyChanged
support where appropriate. - Interface Implementation:
If your class does not already implement interfaces likeIBindableObject
, the generator will add the necessary interface implementations and event wiring. - Thread Safety:
Generated properties use locking patterns to ensure thread safety, matching the patterns used throughout the ThunderDesign.Net-PCL.Threading library.
How to use
Add the NuGet package:
Reference theThunderDesign.Net-PCL.Threading
package in your project. If you are building from source, add a project reference toThunderDesign.Net-PCL.SourceGenerators.csproj
.Annotate your fields:
Use[BindableProperty]
or[Property]
attributes on your fields to indicate which properties should be generated. The generator will handle the rest.Build your project:
When you build, the source generator will automatically add the generated code to your compilation. You do not need to manually include or maintain the generated files.Enjoy less boilerplate:
Your classes will have all the necessary properties, events, and thread-safety mechanisms without manual implementation.
Note: Source generators require Visual Studio 2019 16.9+ or .NET SDK 5.0+ for full support.
Example Usage
Suppose you want to create a thread-safe, bindable object with automatic property and notification support.
With the source generator, you only need to annotate your fields:
using ThunderDesign.Net.Threading.Attributes;
public partial class Person
{
[BindableProperty]
private string _name;
[Property]
private int _age;
}
What gets generated:
- A public
Name
property with thread-safe getter/setter andINotifyPropertyChanged
support. - A public
Age
property with thread-safe getter/setter.
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ThunderDesign.Net.Threading.Extentions;
using ThunderDesign.Net.Threading.Interfaces;
public partial class Person : IBindableObject, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected readonly object _Locker = new object();
public string Name
{
get { return this.GetProperty(ref _name, _Locker); }
set { this.SetProperty(ref _name, value, _Locker, true); }
}
public int Age
{
get { return this.GetProperty(ref _age, _Locker); }
set { this.SetProperty(ref _age, value, _Locker); }
}
}
You can now use your Person
class like this:
var person = new Person();
person.Name = "Alice";
person.Age = 30; // PropertyChanged event will be raised for Name changes if you subscribe to it.
No need to manually implement property notification, thread safety, or boilerplate code—the generator does it for you!
For more advanced scenarios, you can use attribute parameters to control property behavior (e.g., read-only, also notify other properties, etc.).
Installation
Grab the latest ThunderDesign.Net-PCL.Threading NuGet package and install in your solution.
Install-Package ThunderDesign.Net-PCL.Threading
Use the -version
option to specify an older version to install.
Examples
(TIP: Clone repo, open the solution, build it and run sample app.)
- Xamarin
Please Contribute!
This is an open source project that welcomes contributions/suggestions/bug reports from those who use it. If you have any ideas on how to improve the library, please post an issue here on GitHub. Please check out the How to Contribute.
Breaking changes from v1.0.7 to v1.0.8!
Observable Objects now Wait when calling PropertyChanged
Event.
This can be overwritten durring creation or by setting Property WaitOnNotifyPropertyChanged
. Default value is true
.
Observable Collections now Wait when calling CollectionChanged
Event.
This can be overwritten durring creation or by setting Property WaitOnNotifyCollectionChanged
. Default value is true
.
(TIP: If you experience Dead Locks change this value to false
.)
Breaking changes from v1.0.9 to v1.0.10!
Observable Objects Property WaitOnNotifyPropertyChanged
has been renamed to Property WaitOnNotifying
.
Observable Collections Property WaitOnNotifyCollectionChanged
has been removed and now uses Property WaitOnNotifying
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 1.0
- No dependencies.
-
.NETStandard 1.3
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ThunderDesign.Net-PCL.Threading:
Package | Downloads |
---|---|
ThunderDesign.Net-PCL.SQLite
A wrapper around the popular 'sqlite-net-pcl' automating the reading and writing to the database through simple thread-safe bindable objects. |
|
ThunderDesign.Net-PCL.Dynamic
A combination of generic Dynamic Thread-Safe objects that can be used in all application types. |
|
ThunderDesign.Net-PCL.HttpClientService
A wrapper around 'System.Net.Http.HttpClient' enhancing AutoRedirect and Cookies. Can be used in all application types. |
|
ThunderDesign.Xamarin.Forms.FloatingActionButton
FloatingActionButton (FAB) with custom shadow (Color, Offset, Blur) and custom Animation Easing (Show, Hide) for Xamarin.Forms view (Android, iOS, UWP) |
GitHub repositories
This package is not used by any popular GitHub repositories.