当前位置: 首页>>代码示例>>C#>>正文


C# ISchedulingContext类代码示例

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


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


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