• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISchedulingContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISchedulingContext的典型用法代码示例。如果您正苦于以下问题:C# ISchedulingContext类的具体用法?C# ISchedulingContext怎么用?C# ISchedulingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISchedulingContext类属于命名空间,在下文中一共展示了ISchedulingContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InitializeSchedulerForTesting

 internal static OrleansTaskScheduler InitializeSchedulerForTesting(ISchedulingContext context)
 {
     StatisticsCollector.StatisticsCollectionLevel = StatisticsLevel.Info;
     SchedulerStatisticsGroup.Init();
     var scheduler = new OrleansTaskScheduler(4);
     scheduler.Start();
     WorkItemGroup ignore = scheduler.RegisterWorkContext(context);
     return scheduler;
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:9,代码来源:TestInternalHelper.cs


示例2: TaskWorkItem

        /// <summary>
        /// Create a new TaskWorkItem for running the specified Task on the specified scheduler.
        /// </summary>
        /// <param name="sched">Scheduler to execute this Task action. A value of null means use the Orleans system scheduler.</param>
        /// <param name="t">Task to be performed</param>
        /// <param name="context">Execution context</param>
        internal TaskWorkItem(ITaskScheduler sched, Task t, ISchedulingContext context)
        {
            scheduler = sched;
            task = t;
            SchedulingContext = context;
#if DEBUG
            if (logger.IsVerbose2) logger.Verbose2("Created TaskWorkItem {0} for Id={1} State={2} with Status={3} Scheduler={4}",
                Name, task.Id, (task.AsyncState == null) ? "null" : task.AsyncState.ToString(), task.Status, scheduler);
#endif
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:16,代码来源:TaskWorkItem.cs


示例3: InvokeWorkItem

 public InvokeWorkItem(ActivationData activation, Message message, ISchedulingContext context)
 {
     this.activation = activation;
     this.message = message;
     SchedulingContext = context;
     if (activation == null || activation.GrainInstance==null)
     {
         var str = String.Format("Creating InvokeWorkItem with bad activation: {0}. Message: {1}", activation, message);
         logger.Warn(ErrorCode.SchedulerNullActivation, str);
         throw new ArgumentException(str);
     }
     activation.IncrementInFlightCount();
 }
开发者ID:sbambach,项目名称:orleans,代码行数:13,代码来源:InvokeWorkItem.cs


示例4: TimerTick

 private async Task TimerTick(object state, ISchedulingContext context)
 {
     if (TimerAlreadyStopped)
         return;
     try
     {
         await RuntimeClient.Current.ExecAsync(() => ForwardToAsyncCallback(state), context, Name);
     }
     catch (InvalidSchedulingContextException exc)
     {
         logger.Error(ErrorCode.Timer_InvalidContext,
             string.Format("Caught an InvalidSchedulingContextException on timer {0}, context is {1}. Going to dispose this timer!",
                 GetFullName(), context), exc);
         DisposeTimer();
     }
 }
开发者ID:sbambach,项目名称:orleans,代码行数:16,代码来源:GrainTimer.cs


示例5: RegisterWorkContext

        // Only required if you have work groups flagged by a context that is not a WorkGroupingContext
        public WorkItemGroup RegisterWorkContext(ISchedulingContext context)
        {
            if (context == null) return null;

            var wg = new WorkItemGroup(this, context);
            workgroupDirectory.TryAdd(context, wg);
            return wg;
        }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:9,代码来源:OrleansTaskScheduler.cs


示例6: UnregisterWorkContext

        // Only required if you have work groups flagged by a context that is not a WorkGroupingContext
        public void UnregisterWorkContext(ISchedulingContext context)
        {
            if (context == null) return;

            WorkItemGroup workGroup;
            if (workgroupDirectory.TryRemove(context, out workGroup))
                workGroup.Stop();
        }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:9,代码来源:OrleansTaskScheduler.cs


示例7: Equals

 public bool Equals(ISchedulingContext other)
 {
     return base.Equals(other);
 }
开发者ID:osjimenez,项目名称:orleans,代码行数:4,代码来源:OrleansTaskSchedulerBasicTests.cs


示例8: QueueWorkItem

        // Enqueue a work item to a given context
        public void QueueWorkItem(IWorkItem workItem, ISchedulingContext context)
        {
#if DEBUG
            if (logger.IsVerbose2) logger.Verbose2("QueueWorkItem " + context);
#endif
            if (workItem is TaskWorkItem)
            {
                var error = String.Format("QueueWorkItem was called on OrleansTaskScheduler for TaskWorkItem {0} on Context {1}."
                    + " Should only call OrleansTaskScheduler.QueueWorkItem on WorkItems that are NOT TaskWorkItem. Tasks should be queued to the scheduler via QueueTask call.",
                    workItem.ToString(), context);
                logger.Error(ErrorCode.SchedulerQueueWorkItemWrongCall, error);
                throw new InvalidOperationException(error);
            }

            var workItemGroup = GetWorkItemGroup(context);
            if (applicationTurnsStopped && (workItemGroup != null) && !workItemGroup.IsSystem)
            {
                // Drop the task on the floor if it's an application work item and application turns are stopped
                var msg = string.Format("Dropping work item {0} because applicaiton turns are stopped", workItem);
                logger.Warn(ErrorCode.SchedulerAppTurnsStopped, msg);
                return;
            }

            workItem.SchedulingContext = context;

            // We must wrap any work item in Task and enqueue it as a task to the right scheduler via Task.Start.
            // This will make sure the TaskScheduler.Current is set correctly on any task that is created implicitly in the execution of this workItem.
            if (workItemGroup == null)
            {
                Task t = TaskSchedulerUtils.WrapWorkItemAsTask(workItem, context, this);
                t.Start(this);
            }
            else
            {
                // Create Task wrapper for this work item
                Task t = TaskSchedulerUtils.WrapWorkItemAsTask(workItem, context, workItemGroup.TaskRunner);
                t.Start(workItemGroup.TaskRunner);
            }
        }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:40,代码来源:OrleansTaskScheduler.cs


示例9: ExecAsync

 public async Task ExecAsync(Func<Task> asyncFunction, ISchedulingContext context, string activityName)
 {
     // Schedule call back to grain context
     await OrleansTaskScheduler.Instance.QueueNamedTask(asyncFunction, context, activityName);
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:5,代码来源:InsideRuntimeClient.cs


示例10: CheckSchedulingContextValidity

 internal void CheckSchedulingContextValidity(ISchedulingContext context)
 {
     if (context == null)
     {
         throw new InvalidSchedulingContextException(
             "CheckSchedulingContextValidity was called on a null SchedulingContext."
              + "Please make sure you are not trying to create a Timer from outside Orleans Task Scheduler, "
              + "which will be the case if you create it inside Task.Run.");
     }
     GetWorkItemGroup(context); // GetWorkItemGroup throws for Invalid context
 }
开发者ID:jdom,项目名称:orleans,代码行数:11,代码来源:OrleansTaskScheduler.cs


示例11: EnqueueReceiveMessage

        private void EnqueueReceiveMessage(Message msg, ActivationData targetActivation, ISchedulingContext context)
        {
            MessagingProcessingStatisticsGroup.OnImaMessageEnqueued(context);

            if (targetActivation != null) targetActivation.IncrementEnqueuedOnDispatcherCount();

            scheduler.QueueWorkItem(new ClosureWorkItem(() =>
            {
                try
                {
                    dispatcher.ReceiveMessage(msg);
                }
                finally
                {
                    if (targetActivation != null) targetActivation.DecrementEnqueuedOnDispatcherCount();
                }
            },
            () => "Dispatcher.ReceiveMessage"), context);
        }
开发者ID:PaulNorth,项目名称:orleans,代码行数:19,代码来源:IncomingMessageAgent.cs


示例12: GetTaskScheduler

 public TaskScheduler GetTaskScheduler(ISchedulingContext context)
 {
     if (context == null)
         return this;
     
     WorkItemGroup workGroup;
     return workgroupDirectory.TryGetValue(context, out workGroup) ? (TaskScheduler) workGroup.TaskRunner : this;
 }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:8,代码来源:OrleansTaskScheduler.cs


示例13: GetWorkItemGroup

 // public for testing only -- should be private, otherwise
 public WorkItemGroup GetWorkItemGroup(ISchedulingContext context)
 {
     WorkItemGroup workGroup = null;
     if (context != null)
         workgroupDirectory.TryGetValue(context, out workGroup);
     
     return workGroup;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:9,代码来源:OrleansTaskScheduler.cs


示例14: Equals

 public bool Equals(ISchedulingContext other)
 {
     return AreSame(other);
 }
开发者ID:stanroze,项目名称:orleans,代码行数:4,代码来源:SchedulingContext.cs


示例15: UnobservedExceptionHandler

 private void UnobservedExceptionHandler(ISchedulingContext context, Exception exception)
 {
     var schedulingContext = context as SchedulingContext;
     if (schedulingContext == null)
     {
         if (context == null)
             logger.Error(ErrorCode.Runtime_Error_100102, "Silo caught an UnobservedException with context==null.", exception);
         else
             logger.Error(ErrorCode.Runtime_Error_100103, String.Format("Silo caught an UnobservedException with context of type different than OrleansContext. The type of the context is {0}. The context is {1}",
                 context.GetType(), context), exception);
     }
     else
     {
         logger.Error(ErrorCode.Runtime_Error_100104, String.Format("Silo caught an UnobservedException thrown by {0}.", schedulingContext.Activation), exception);
     }   
 }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:16,代码来源:Silo.cs


示例16: OnImaMessageEnqueued

 internal static void OnImaMessageEnqueued(ISchedulingContext context)
 {
     if (context == null)
     {
         imaEnqueuedByContext[0].Increment();
     }
     else if (context.ContextType == SchedulingContextType.SystemTarget)
     {
         imaEnqueuedByContext[1].Increment();
     }
     else if (context.ContextType == SchedulingContextType.Activation)
     {
         imaEnqueuedByContext[2].Increment();
     }
 }
开发者ID:stanroze,项目名称:orleans,代码行数:15,代码来源:MessagingProcessingStatisticsGroup.cs


示例17: WrapWorkItemAsTask

 internal static Task WrapWorkItemAsTask(IWorkItem todo, ISchedulingContext context, TaskScheduler sched)
 {
     var task = new Task(state => RunWorkItemTask(todo, sched), context);
     return task;
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:5,代码来源:TaskSchedulerUtils.cs


示例18: GetWorkItemGroup

        // public for testing only -- should be private, otherwise
        public WorkItemGroup GetWorkItemGroup(ISchedulingContext context)
        {
            if (context == null)
                return null;
           
            WorkItemGroup workGroup;
            if(workgroupDirectory.TryGetValue(context, out workGroup))
                return workGroup;

            var error = String.Format("QueueWorkItem was called on a non-null context {0} but there is no valid WorkItemGroup for it.", context);
            logger.Error(ErrorCode.SchedulerQueueWorkItemWrongContext, error);
            throw new InvalidSchedulingContextException(error);
        }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:14,代码来源:OrleansTaskScheduler.cs


示例19: SetExecutionContext

 internal static void SetExecutionContext(ISchedulingContext shedContext, TaskScheduler scheduler)
 {
     if (context == null) throw new InvalidOperationException("SetExecutionContext called on unexpected non-WorkerPool thread");
     context.ActivationContext = shedContext;
     context.Scheduler = scheduler;
 }
开发者ID:JackWangCUMT,项目名称:orleans,代码行数:6,代码来源:RuntimeContext.cs


示例20: CheckSchedulingContextValidity

 internal void CheckSchedulingContextValidity(ISchedulingContext context)
 {
     if (context == null)
     {
         throw new InvalidSchedulingContextException("CheckSchedulingContextValidity was called on a null SchedulingContext.");
     }
     GetWorkItemGroup(context); // GetWorkItemGroup throws for Invalid context
 }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:8,代码来源:OrleansTaskScheduler.cs



注:本文中的ISchedulingContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISchema类代码示例发布时间:2022-05-24
下一篇:
C# ISchedulerService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap