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 toRealm.ResolveReference
.
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
| Edit this page View SourceCreate<TValue>(IDictionary<string, TValue>)
Initializes a new instance of the ThreadSafeReference.Dictionary<TValue> class.
Declaration
public static ThreadSafeReference.Dictionary<TValue> Create<TValue>(IDictionary<string, TValue> value)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<string, TValue> | value | The thread-confined IDictionary<TKey, TValue> to create a thread-safe reference to. It must be a collection that is a managed property of a RealmObject or an EmbeddedObject. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Dictionary<TValue> | A ThreadSafeReference that can be passed to ResolveReference<TValue>(Dictionary<TValue>) on a different thread. |
Type Parameters
Name | Description |
---|---|
TValue | The type of the values contained in the dictionary. |
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 that is a managed property of a RealmObject or an EmbeddedObject. |
Returns
Type | Description |
---|---|
ThreadSafeReference.List<T> | A ThreadSafeReference that can be passed to ResolveReference<T>(List<T>) on a different thread. |
Type Parameters
Name | Description |
---|---|
T | The type of the objects contained in the list. |
Create<T>(ISet<T>)
Initializes a new instance of the ThreadSafeReference.Set<T> class.
Declaration
public static ThreadSafeReference.Set<T> Create<T>(ISet<T> value)
Parameters
Type | Name | Description |
---|---|---|
ISet<T> | value | The thread-confined ISet<T> to create a thread-safe reference to. It must be a collection that is a managed property of a RealmObject or an EmbeddedObject. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Set<T> | A ThreadSafeReference that can be passed to ResolveReference<T>(Set<T>) on a different thread. |
Type Parameters
Name | Description |
---|---|
T | The type of the objects contained in the set. |
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)
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<T>() or a subsequent LINQ query. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Query<T> | A ThreadSafeReference that can be passed to ResolveReference<T>(Query<T>) on a different thread. |
Type Parameters
Name | Description |
---|---|
T | The type of the RealmObject or EmbeddedObject contained in the query. |
Create<T>(T)
Initializes a new instance of the ThreadSafeReference.Object<T> class.
Declaration
public static ThreadSafeReference.Object<T> Create<T>(T value) where T : IRealmObjectBase
Parameters
Type | Name | Description |
---|---|---|
T | value | The thread-confined RealmObject or EmbeddedObject to create a thread-safe reference to. |
Returns
Type | Description |
---|---|
ThreadSafeReference.Object<T> | A ThreadSafeReference that can be passed to ResolveReference<T>(Object<T>) on a different thread. |
Type Parameters
Name | Description |
---|---|
T | The type of the RealmObject/EmbeddedObject. |