// This works wrong! obj is locked but not the underlaying object!
 static void DoSomethingAsyncIncorrectly(ISynchronized obj)
 {
     lock (obj)
     {
         // Do something with obj
     }
 }
 /// <summary>
 /// Executes the specified <paramref name="func"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> and returns the result
 /// </summary>
 /// <typeparam name="TResult">The return type of <paramref name="func"/></typeparam>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="func">The <see cref="Func{TResult}"/></param>
 /// <returns>The result of <paramref name="func"/></returns>
 public static TResult Execute <TResult>(this ISynchronized synchronizable, Func <TResult> func) => Execute(synchronizable.SynchronizationContext, func);
 /// <summary>
 /// Executes the specified <paramref name="action"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/>
 /// </summary>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="action">The <see cref="Action"/></param>
 public static void Execute(this ISynchronized synchronizable, Action action) => Execute(synchronizable.SynchronizationContext, action);
 /// <summary>
 /// Executes the specified <paramref name="asyncFunc"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> (or <see cref="Synchronization.DefaultSynchronizationContext"/> if that is <c>null</c>) and returns the result
 /// </summary>
 /// <typeparam name="TResult">The return type of <paramref name="asyncFunc"/></typeparam>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="asyncFunc">The <see cref="Func{Task}"/> that returns a value</param>
 /// <returns>The result of <paramref name="asyncFunc"/></returns>
 public static Task <TResult> SequentialExecuteAsync <TResult>(this ISynchronized synchronizable, Func <Task <TResult> > asyncFunc) => ExecuteAsync(synchronizable?.SynchronizationContext ?? Synchronization.DefaultSynchronizationContext, asyncFunc);
 /// <summary>
 /// Executes the specified <paramref name="asyncAction"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> (or <see cref="Synchronization.DefaultSynchronizationContext"/> if that is <c>null</c>)
 /// </summary>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="asyncAction">The <see cref="Func{Task}"/></param>
 public static Task SequentialExecuteAsync(this ISynchronized synchronizable, Func <Task> asyncAction) => ExecuteAsync(synchronizable?.SynchronizationContext ?? Synchronization.DefaultSynchronizationContext, asyncAction);
 /// <summary>
 /// Executes the specified <paramref name="func"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> (or <see cref="Synchronization.DefaultSynchronizationContext"/> if that is <c>null</c>) and returns the result
 /// </summary>
 /// <typeparam name="TResult">The return type of <paramref name="func"/></typeparam>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="func">The <see cref="Func{TResult}"/></param>
 /// <returns>The result of <paramref name="func"/></returns>
 public static TResult SequentialExecute <TResult>(this ISynchronized synchronizable, Func <TResult> func) => Execute(synchronizable?.SynchronizationContext ?? Synchronization.DefaultSynchronizationContext, func);
 /// <summary>
 /// Executes the specified <paramref name="action"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> (or <see cref="Synchronization.DefaultSynchronizationContext"/> if that is <c>null</c>)
 /// </summary>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="action">The <see cref="Action"/></param>
 public static void SequentialExecute(this ISynchronized synchronizable, Action action) => Execute(synchronizable?.SynchronizationContext ?? Synchronization.DefaultSynchronizationContext, action);
 /// <summary>
 /// Executes the specified <paramref name="asyncFunc"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/> and returns the result
 /// </summary>
 /// <typeparam name="TResult">The return type of <paramref name="asyncFunc"/></typeparam>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="asyncFunc">The <see cref="Func{Task}"/> that returns a value</param>
 /// <returns>The result of <paramref name="asyncFunc"/></returns>
 public static Task <TResult> ExecuteAsync <TResult>(this ISynchronized synchronizable, Func <Task <TResult> > asyncFunc) => ExecuteAsync(synchronizable.SynchronizationContext, asyncFunc);
 /// <summary>
 /// Executes the specified <paramref name="asyncAction"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/>
 /// </summary>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="asyncAction">The <see cref="Func{Task}"/></param>
 public static Task ExecuteAsync(this ISynchronized synchronizable, Func <Task> asyncAction) => ExecuteAsync(synchronizable.SynchronizationContext, asyncAction);
Beispiel #10
0
 /// <summary>
 /// Executes the specified <paramref name="action"/> on the <see cref="ISynchronized.SynchronizationContext"/> of the specified <paramref name="synchronizable"/>
 /// </summary>
 /// <param name="synchronizable">The <see cref="ISynchronized"/></param>
 /// <param name="action">The <see cref="Action"/></param>
 public static Task ExecuteAsync(this ISynchronized synchronizable, Action action) => ExecuteAsync(synchronizable.SynchronizationContext, action);
Beispiel #11
0
 public NotifyStatusChangedEventArgs(ISynchronized item)
 {
     Item = item;
 }
Beispiel #12
0
 public SynchronizedController(ISynchronized synchronized, IElasticClient elasticClient)
 {
     _synchronized  = synchronized;
     _elasticClient = elasticClient;
 }
 // note that this function only exists to provide access to feature
 // that is normally not accessible due to the limitations of the monitor
 public static void SetSyncDomainFromEmulation(this ISynchronized @this, int domainIndex)
 {
     @this.SyncDomain = EmulationManager.Instance.CurrentEmulation.SyncDomains[domainIndex];
 }
 public WrapperB(ISynchronized subClass)
 {
     this.subClass = subClass;
 }