本文整理汇总了C#中IRunnable类的典型用法代码示例。如果您正苦于以下问题:C# IRunnable类的具体用法?C# IRunnable怎么用?C# IRunnable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRunnable类属于命名空间,在下文中一共展示了IRunnable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RejectedExecution
/// <summary>
/// Obtains and ignores the next task that the <paramref name="executor"/>
/// would otherwise execute, if one is immediately available,
/// and then retries execution of task <paramref name="runnable"/>, unless the <paramref name="executor"/>
/// is shut down, in which case task <paramref name="runnable"/> is instead discarded.
/// </summary>
/// <param name="runnable">the <see cref="Spring.Threading.IRunnable"/> task requested to be executed</param>
/// <param name="executor">the <see cref="Spring.Threading.Execution.ThreadPoolExecutor"/> attempting to execute this task</param>
public virtual void RejectedExecution(IRunnable runnable, ThreadPoolExecutor executor)
{
if (executor.IsShutdown) return;
IRunnable head;
executor.Queue.Poll(out head);
executor.Execute(runnable);
}
示例2: CacheHostEngine
/// <summary>
/// The constructor.
/// </summary>
/// <param name="cacheHostInformationPoller">The cache host information poller.</param>
/// <param name="memCache">The mem cache to use for storing objects.</param>
/// <param name="clientToCacheServiceHost">The client to cache service host.</param>
/// <param name="cacheManagerClient">The cache manager client.</param>
public CacheHostEngine(IRunnable cacheHostInformationPoller, MemCache memCache, ServiceHost clientToCacheServiceHost)
{
// Sanitize
if (cacheHostInformationPoller == null)
{
throw new ArgumentNullException("cacheHostInformationPoller");
}
if (memCache == null)
{
throw new ArgumentNullException("memCache");
}
if (clientToCacheServiceHost == null)
{
throw new ArgumentNullException("clientToCacheServiceHost");
}
// Set the cache host information poller
_cacheHostInformationPoller = cacheHostInformationPoller;
// Set the mem cache container instance
MemCacheContainer.Instance = memCache;
// Initialize the service hosts
_clientToCacheServiceHost = clientToCacheServiceHost;
}
示例3: NewThread
public Thread NewThread (IRunnable r)
{
Thread t = new Thread (r);
t.SetDaemon (true);
t.Start ();
return t;
}
示例4: RunnableTask
/**
* Builds the task.
*
* @param runnable
* The wrapped Runnable object.
* @throws InvalidPatternException
* If the supplied pattern is not valid.
*/
public RunnableTask(IRunnable runnable)
{
if (runnable == null)
throw new ArgumentNullException("runnable", "runnable is null.");
this._runnable = runnable;
}
示例5: Sync
public override void Sync(IRunnable runnable)
{
lock (_bin)
{
base.Sync(runnable);
}
}
示例6: postOnAnimation
public static void postOnAnimation(View view, IRunnable runnable) {
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) {
SDK16.postOnAnimation(view, runnable);
} else {
view.PostDelayed(runnable, 16);
}
}
示例7: produce
private Object produce(IRunnable runnable, Object result)
{
var producers = runnableManager.GetProducers(runnable);
var converter = producers.FirstOrDefault(c => c.IsConvertable(result));
if (converter == null) return result;
return converter.Convert(result);
}
示例8: PostRunnable
// ===========================================================
// Methods
// ===========================================================
public void PostRunnable(/* final */ IRunnable pRunnable)
{
lock (_methodLock)
{
this.mRunnables.Add(pRunnable);
}
}
示例9: SetUp
public void SetUp()
{
_queue = MockRepository.GenerateStub<IBlockingQueue<IRunnable>>();
_runnable = MockRepository.GenerateMock<IRunnable>();
_callerRunsPolicy = new ThreadPoolExecutor.CallerRunsPolicy();
_threadPoolExecutor = new ThreadPoolExecutor(1, 1, TimeSpan.FromSeconds(1), _queue);
}
示例10: consume
private Object consume(IRunnable runnable, Object parameter)
{
var consumers = runnableManager.GetConsumers(runnable);
var converter = consumers.FirstOrDefault(c => c.IsConvertable(parameter));
if (converter == null) return ExecuteRunnable(runnable, parameter);
return converter.Convert(parameter, param => ExecuteRunnable(runnable, param));
}
示例11: SetUp
public void SetUp()
{
_queue = MockRepository.GenerateStub<IBlockingQueue<IRunnable>>();
_runnable = MockRepository.GenerateMock<IRunnable>();
_discardOldestPolicy = new ThreadPoolExecutor.DiscardOldestPolicy();
_threadPoolExecutor = Mockery.GeneratePartialMock<ThreadPoolExecutor>(1, 1, TimeSpan.FromSeconds(1), _queue);
}
示例12: Queue
public override void Queue(IRunnable runnable)
{
using (RWLock.AsReader(_lock))
{
SelectQueue(_lock, _queues, runnable).Enqueue(runnable);
}
}
示例13: PostOnAnimation
public static void PostOnAnimation(View view, IRunnable runnable)
{
if ((int)Android.OS.Build.VERSION.SdkInt >= (int)Android.OS.Build.VERSION_CODES.JellyBean) {
PostOnAnimationJellyBean(view, runnable);
} else {
view.PostDelayed(runnable, SIXTY_FPS_INTERVAL);
}
}
示例14: Execute
public void Execute(IRunnable command)
{
if (!this.IsAcceptingNewTasks)
{
throw new RejectedExecutionException();
}
this.Unwrap().Execute(command);
}
示例15: AssignExceptionHandler
/// <summary> Returns wrapped runnable that ensures that if an exception occurs
/// during the execution, the specified exception handler is invoked.
/// </summary>
/// <param name="runnable">runnable for which exceptions are to be intercepted
/// </param>
/// <param name="handler">the exception handler to call when exception occurs
/// during execution of the given runnable
/// </param>
/// <returns> wrapped runnable
/// </returns>
/// <exception cref="System.ArgumentNullException">If either parameter is <c>null</c></exception>
public static IRunnable AssignExceptionHandler(IRunnable runnable, UncaughtExceptionHandlerDelegate handler)
{
if ( runnable == null )
throw new ArgumentNullException("runnable", "Runnable cannot be null");
if ( handler == null )
throw new ArgumentNullException("handler", "Handler cannot be null");
return new AnonymousClassRunnable(runnable, handler);
}