Пример #1
0
 // This works wrong! obj is locked but not the underlaying object!
 static void DoSomethingAsyncIncorrectly(ISynchronized obj)
 {
     lock (obj)
     {
         // Do something with obj
     }
 }
Пример #2
0
 /// <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);
Пример #3
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 void Execute(this ISynchronized synchronizable, Action action) => Execute(synchronizable.SynchronizationContext, action);
Пример #4
0
 /// <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);
Пример #5
0
 /// <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);
Пример #6
0
 /// <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);
Пример #7
0
 /// <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);
Пример #8
0
 /// <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);
Пример #9
0
 /// <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);
Пример #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);
Пример #11
0
 public NotifyStatusChangedEventArgs(ISynchronized item)
 {
     Item = item;
 }
Пример #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];
 }
Пример #14
0
 public WrapperB(ISynchronized subClass)
 {
     this.subClass = subClass;
 }