Class ThreadSafeReference
An object intended to be passed between threads containing a thread-safe reference to its thread-confined object.
To resolve a thread-safe reference on a target Realm on a different thread, pass it to
Realm.ResolveReference
.
Inheritance
Inherited Members
Namespace: Realms
Assembly: Realm.dll
Syntax
public abstract class ThreadSafeReference
Remarks
A ThreadSafeReference object must be resolved at most once.
Failing to resolve a ThreadSafeReference will result in the source version of the Realm being pinned until the reference is deallocated.
Prefer short-lived ThreadSafeReferences as the data for the version of the source Realm will be retained until all references have been resolved or deallocated.
Methods
| Improve this Doc View SourceCreate<T>(T)
Initializes a new instance of the ThreadSafeReference.Object<T> class.
Declaration
public static ThreadSafeReference.Object<T> Create<T>(T value)
where T : RealmObject
Parameters
Type | Name | Description |
---|---|---|
T | value | The thread-confined RealmObject to create a thread-safe reference to. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Object<T> | A ThreadSafeReference that can be passed to |
Type Parameters
Name | Description |
---|---|
T | The type of the RealmObject. |
Create<T>(IList<T>)
Initializes a new instance of the ThreadSafeReference.List<T> class.
Declaration
public static ThreadSafeReference.List<T> Create<T>(IList<T> value)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | value | The thread-confined IList<T> to create a thread-safe reference to. It must be a collection representing to-many relationship as a property of a RealmObject |
Returns
Type | Description |
---|---|
ThreadSafeReference.List<T> | A ThreadSafeReference that can be passed to |
Type Parameters
Name | Description |
---|---|
T | The type of the objects contained in the list. |
Create<T>(IQueryable<T>)
Initializes a new instance of the ThreadSafeReference.Query<T> class.
Declaration
public static ThreadSafeReference.Query<T> Create<T>(IQueryable<T> value)
where T : RealmObject
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | value | The thread-confined IQueryable<T> to create a thread-safe reference to. It must be a collection, obtained by calling All(String) or a subsequent LINQ query. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Query<T> | A ThreadSafeReference that can be passed to |
Type Parameters
Name | Description |
---|---|
T | The type of the RealmObject contained in the query. |