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


C# Runtime.Message类代码示例

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


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

示例1: RequestInvocationHistory

 internal RequestInvocationHistory(Message message)
 {
     GrainId = message.TargetGrain;
     ActivationId = message.TargetActivation;
     InterfaceId = message.InterfaceId;
     MethodId = message.MethodId;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:7,代码来源:RequestInvocationHistory.cs

示例2: OnDispatcherMessageReceive

 internal static void OnDispatcherMessageReceive(Message msg)
 {
     ISchedulingContext context = RuntimeContext.Current != null ? RuntimeContext.Current.ActivationContext : null;
     dispatcherMessagesProcessingReceivedPerDirection[(int)msg.Direction].Increment();
     dispatcherMessagesReceivedTotal.Increment();
     if (context == null)
     {
         dispatcherReceivedByContext[0].Increment();
     }
     else if (context.ContextType == SchedulingContextType.Activation)
     {
         dispatcherReceivedByContext[1].Increment();
     }
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:14,代码来源:MessagingProcessingStatisticsGroup.cs

示例3: CallbackData

        public Message Message { get; set; } // might hold metadata used by response pipeline

        public CallbackData(Action<Message, TaskCompletionSource<object>> callback, Func<Message, bool> resendFunc, TaskCompletionSource<object> ctx, Message msg, Action unregisterDelegate, Action<CallbackData> onTimeout = null)
        {
            // We are never called without a callback func, but best to double check.
            if (callback == null) throw new ArgumentNullException("callback");
            // We are never called without a resend func, but best to double check.
            if (resendFunc == null) throw new ArgumentNullException("resendFunc");

            this.callback = callback;
            this.resendFunc = resendFunc;
            this.context = ctx;
            this.Message = msg;
            this.unregister = unregisterDelegate;
            this.alreadyFired = false;
            this.onTimeout = onTimeout;
        }
开发者ID:stanroze,项目名称:orleans,代码行数:17,代码来源:CallbackData.cs

示例4: Pong

        public Task Pong(IDestination @from, Message message)
        {
            pongs++;

            if (pings < repeats)
            {
                actor.Ping(this, msg);
                pings++;
            }
            else if (pongs >= repeats)
            {
                subscribers.Notify(x => x.Done(pings, pongs));
            }

            return TaskDone.Done;
        }
开发者ID:dVakulen,项目名称:Orleans.PingPong,代码行数:16,代码来源:Implementations.cs

示例5: CreateMessage

        internal static Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var message = new Message(
                Message.Categories.Application,
                (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request)
            {
                Id = CorrelationId.GetNext(),
                InterfaceId = request.InterfaceId,
                MethodId = request.MethodId,
                IsReadOnly = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered = (options & InvokeMethodOptions.Unordered) != 0,
                BodyObject = request
            };
            
            if ((options & InvokeMethodOptions.AlwaysInterleave) != 0)
                message.IsAlwaysInterleave = true;

            RequestContext.ExportToMessage(message);
            return message;
        }
开发者ID:stanroze,项目名称:orleans,代码行数:20,代码来源:RuntimeClient.cs

示例6: CallbackData

        public Message Message { get; set; } // might hold metadata used by response pipeline

        public CallbackData(
            Action<Message, TaskCompletionSource<object>> callback, 
            Func<Message, bool> resendFunc, 
            TaskCompletionSource<object> ctx, 
            Message msg, 
            Action<Message> unregisterDelegate,
            IMessagingConfiguration config)
        {
            // We are never called without a callback func, but best to double check.
            if (callback == null) throw new ArgumentNullException(nameof(callback));
            // We are never called without a resend func, but best to double check.
            if (resendFunc == null) throw new ArgumentNullException(nameof(resendFunc));

            this.callback = callback;
            this.resendFunc = resendFunc;
            context = ctx;
            Message = msg;
            unregister = unregisterDelegate;
            alreadyFired = false;
            this.config = config;
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:23,代码来源:CallbackData.cs

示例7: TryResendMessage

        private bool TryResendMessage(Message message)
        {
            if (!message.MayResend(config))
            {
                return false;
            }

            if (logger.IsVerbose) logger.Verbose("Resend {0}", message);

            message.ResendCount = message.ResendCount + 1;
            message.SetMetadata(Message.Metadata.TARGET_HISTORY, message.GetTargetHistory());
            
            if (!message.TargetGrain.IsSystemTarget)
            {
                message.RemoveHeader(Message.Header.TARGET_ACTIVATION);
                message.RemoveHeader(Message.Header.TARGET_SILO);
            }
            transport.SendMessage(message);
            return true;
        }
开发者ID:randa1,项目名称:orleans,代码行数:20,代码来源:OutsideRuntimeClient.cs

示例8: SendResponse

        private void SendResponse(Message request, Response response)
        {
            var message = request.CreateResponseMessage();
            message.BodyObject = response;

            transport.SendMessage(message);
        }
开发者ID:randa1,项目名称:orleans,代码行数:7,代码来源:OutsideRuntimeClient.cs

示例9: SendResponseAsync

            SendResponseAsync(
                Message message,
                object resultObject)
        {
            if (ExpireMessageIfExpired(message, MessagingStatisticsGroup.Phase.Respond))
                return TaskDone.Done;

            object deepCopy = null;
            try
            {
                // we're expected to notify the caller if the deep copy failed.
                deepCopy = SerializationManager.DeepCopy(resultObject);
            }
            catch (Exception exc2)
            {
                SendResponse(message, Response.ExceptionResponse(exc2));
                logger.Warn(
                    ErrorCode.ProxyClient_OGC_SendResponseFailed,
                    "Exception trying to send a response.", exc2);
                return TaskDone.Done;
            }

            // the deep-copy succeeded.
            SendResponse(message, new Response(deepCopy));
            return TaskDone.Done;
        }
开发者ID:randa1,项目名称:orleans,代码行数:26,代码来源:OutsideRuntimeClient.cs

示例10: InvokeLocalObjectAsync

        private void InvokeLocalObjectAsync(LocalObjectData objectData, Message message)
        {
            var obj = (IAddressable)objectData.LocalObject.Target;
            if (obj == null)
            {
                //// Remove from the dictionary record for the garbage collected object? But now we won't be able to detect invalid dispatch IDs anymore.
                logger.Warn(ErrorCode.Runtime_Error_100162,
                    String.Format("Object associated with Observer ID {0} has been garbage collected. Deleting object reference and unregistering it. Message = {1}", objectData.ObserverId, message));

                LocalObjectData ignore;
                // Try to remove. If it's not there, we don't care.
                localObjects.TryRemove(objectData.ObserverId, out ignore);
                return;
            }

            bool start;
            lock (objectData.Messages)
            {
                objectData.Messages.Enqueue(message);
                start = !objectData.Running;
                objectData.Running = true;
            }
            if (logger.IsVerbose) logger.Verbose("InvokeLocalObjectAsync {0} start {1}", message, start);
            if (start)
            {
                // we use Task.Run() to ensure that the message pump operates asynchronously
                // with respect to the current thread. see 
                // http://channel9.msdn.com/Events/TechEd/Europe/2013/DEV-B317#fbid=aIWUq0ssW74
                // at position 54:45. 
                //
                // according to the information posted at:
                // http://stackoverflow.com/questions/12245935/is-task-factory-startnew-guaranteed-to-use-another-thread-than-the-calling-thr
                // this idiom is dependent upon the a TaskScheduler not implementing the
                // override QueueTask as task inlining (as opposed to queueing). this seems 
                // implausible to the author, since none of the .NET schedulers do this and
                // it is considered bad form (the OrleansTaskScheduler does not do this).
                //
                // if, for some reason this doesn't hold true, we can guarantee what we
                // want by passing a placeholder continuation token into Task.StartNew() 
                // instead. i.e.:
                //
                // return Task.StartNew(() => ..., new CancellationToken()); 
                Func<Task> asyncFunc =
                    async () =>
                        await this.LocalObjectMessagePumpAsync(objectData);
                Task.Run(asyncFunc).Ignore();
            }
        }
开发者ID:randa1,项目名称:orleans,代码行数:48,代码来源:OutsideRuntimeClient.cs

示例11: RejectMessage

        private void RejectMessage(Message msg, string reasonFormat, params object[] reasonParams)
        {
            if (!Running) return;

            var reason = String.Format(reasonFormat, reasonParams);
            if (msg.Direction != Message.Directions.Request)
            {
                if (logger.IsVerbose) logger.Verbose(ErrorCode.ProxyClient_DroppingMsg, "Dropping message: {0}. Reason = {1}", msg, reason);
            }
            else
            {
                if (logger.IsVerbose) logger.Verbose(ErrorCode.ProxyClient_RejectingMsg, "Rejecting message: {0}. Reason = {1}", msg, reason);
                MessagingStatisticsGroup.OnRejectedMessage(msg);
                Message error = msg.CreateRejectionResponse(Message.RejectionTypes.Unrecoverable, reason);
                QueueIncomingMessage(error);
            }
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:17,代码来源:ProxiedMessageCenter.cs

示例12: WaitMessage

        public Message WaitMessage(Message.Categories type, CancellationToken ct)
        {
            try
            {
                if (ct.IsCancellationRequested)
                {
                    return null;
                }

                // Don't pass CancellationToken to Take. It causes too much spinning.
                Message msg = PendingInboundMessages.Take();
#if TRACK_DETAILED_STATS
                if (StatisticsCollector.CollectQueueStats)
                {
                    queueTracking.OnDeQueueRequest(msg);
                }
#endif
                return msg;
            }
#if !NETSTANDARD
            catch (ThreadAbortException exc)
            {
                // Silo may be shutting-down, so downgrade to verbose log
                logger.Verbose(ErrorCode.ProxyClient_ThreadAbort, "Received thread abort exception -- exiting. {0}", exc);
                Thread.ResetAbort();
                return null;
            }
#endif
            catch (OperationCanceledException exc)
            {
                logger.Verbose(ErrorCode.ProxyClient_OperationCancelled, "Received operation cancelled exception -- exiting. {0}", exc);
                return null;
            }
            catch (ObjectDisposedException exc)
            {
                logger.Verbose(ErrorCode.ProxyClient_OperationCancelled, "Received Object Disposed exception -- exiting. {0}", exc);
                return null;
            }
            catch (InvalidOperationException exc)
            {
                logger.Verbose(ErrorCode.ProxyClient_OperationCancelled, "Received Invalid Operation exception -- exiting. {0}", exc);
                return null;
            }
            catch (Exception ex)
            {
                logger.Error(ErrorCode.ProxyClient_ReceiveError, "Unexpected error getting an inbound message", ex);
                return null;
            }
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:49,代码来源:ProxiedMessageCenter.cs

示例13: OnRejectedMessage

 internal static void OnRejectedMessage(Message msg)
 {
     if (msg == null || !msg.ContainsHeader(Message.Header.DIRECTION)) return;
     int direction = (int)msg.Direction;
     if (RejectedMessages[direction] == null)
     {
         RejectedMessages[direction] = CounterStatistic.FindOrCreate(
             new StatisticName(StatisticNames.MESSAGING_REJECTED_PER_DIRECTION, Enum.GetName(typeof(Message.Directions), direction)));
     }
     RejectedMessages[direction].Increment();
 }
开发者ID:stanroze,项目名称:orleans,代码行数:11,代码来源:MessagingStatisticsGroup.cs

示例14: OnMessageReceive

 internal static void OnMessageReceive(Message msg, int headerBytes, int bodyBytes)
 {
     MessagesReceived.Increment();
     MessagesReceivedPerDirection[(int)msg.Direction].Increment();
     totalBytesReceived.IncrementBy(headerBytes + bodyBytes);
     headerBytesReceived.IncrementBy(headerBytes);
     receiveMsgSizeHistogram.AddData(headerBytes + bodyBytes);
     SiloAddress addr = msg.SendingSilo;
     FindCounter(perSiloReceiveCounters, new StatisticName(StatisticNames.MESSAGING_RECEIVED_MESSAGES_PER_SILO, (addr != null ? addr.ToString() : "Null")), CounterStorage.LogOnly).Increment();
 }
开发者ID:stanroze,项目名称:orleans,代码行数:10,代码来源:MessagingStatisticsGroup.cs

示例15: OnMessageSend_Impl

 private static void OnMessageSend_Impl(SiloAddress targetSilo, Message.Directions direction, int numTotalBytes, int headerBytes, int numMsgsInBatch)
 {
     MessagesSentTotal.IncrementBy(numMsgsInBatch);
     MessagesSentPerDirection[(int)direction].IncrementBy(numMsgsInBatch);
     TotalBytesSent.IncrementBy(numTotalBytes);
     HeaderBytesSent.IncrementBy(headerBytes);
     sentMsgSizeHistogram.AddData(numTotalBytes);
     FindCounter(perSiloSendCounters, new StatisticName(StatisticNames.MESSAGING_SENT_MESSAGES_PER_SILO, (targetSilo != null ? targetSilo.ToString() : "Null")), CounterStorage.LogOnly).IncrementBy(numMsgsInBatch);
 }
开发者ID:stanroze,项目名称:orleans,代码行数:9,代码来源:MessagingStatisticsGroup.cs


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