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

C# MessageHandler类代码示例

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

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



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

示例1: SocketClient

		/// <summary> 
		/// Constructor for client support
		/// </summary>
		/// <param name="sizeOfRawBuffer"> The size of the raw buffer </param>
		/// <param name="userArg"> A Reference to the Users arguments </param>
		/// <param name="messageHandler">  Reference to the user defined message handler method </param>
		/// <param name="closeHandler">  Reference to the user defined close handler method </param>
		/// <param name="errorHandler">  Reference to the user defined error handler method </param>
		public SocketClient(int sizeOfRawBuffer, object userArg, 
			MessageHandler messageHandler, CloseHandler closeHandler, 
			ErrorHandler errorHandler, ConnectHandler connectHandler)
		{
			// Create the raw buffer
			this.SizeOfRawBuffer = sizeOfRawBuffer;
			this.RawBuffer  = new Byte[this.SizeOfRawBuffer];

			// Save the user argument
			this.userArg = userArg;

			// Set the handler methods
			this.messageHandler = messageHandler;
			this.closeHandler = closeHandler;
			this.errorHandler = errorHandler;
            this.connectHandler = connectHandler;

			// Set the async socket method handlers
			this.callbackReadMethod  = new AsyncCallback(ReceiveComplete);
			this.callbackWriteMethod = new AsyncCallback(SendComplete);
            this.callbackWriteHeadMethod = new AsyncCallback(SendHead);

			this.m_Connected = true;
			// Init the dispose flag
			this.disposed = false;
		}
开发者ID:kingstop,项目名称:crashmo,代码行数:34,代码来源:SocketClient.cs


示例2: StartConsumers

        static void StartConsumers()
        {
            var messageHandler = new MessageHandler();

            //Start four consumers.
            var consumer1 = new Consumer("Consumer1", "group1").Subscribe("SampleTopic").Start(messageHandler);
            var consumer2 = new Consumer("Consumer2", "group1").Subscribe("SampleTopic").Start(messageHandler);
            var consumer3 = new Consumer("Consumer3", "group1").Subscribe("SampleTopic").Start(messageHandler);
            var consumer4 = new Consumer("Consumer4", "group1").Subscribe("SampleTopic").Start(messageHandler);

            //Below to wait for consumer balance.
            var scheduleService = ObjectContainer.Resolve<IScheduleService>();
            var waitHandle = new ManualResetEvent(false);
            var taskId = scheduleService.ScheduleTask(() =>
            {
                var c1AllocatedQueueIds = consumer1.GetCurrentQueues().Select(x => x.QueueId);
                var c2AllocatedQueueIds = consumer2.GetCurrentQueues().Select(x => x.QueueId);
                var c3AllocatedQueueIds = consumer3.GetCurrentQueues().Select(x => x.QueueId);
                var c4AllocatedQueueIds = consumer4.GetCurrentQueues().Select(x => x.QueueId);
                if (c1AllocatedQueueIds.Count() == 1 && c2AllocatedQueueIds.Count() == 1 && c3AllocatedQueueIds.Count() == 1 && c4AllocatedQueueIds.Count() == 1)
                {
                    Console.WriteLine(string.Format("Consumer message queue allocation result: c1:{0}, c2:{1}, c3:{2}, c4:{3}",
                        string.Join(",", c1AllocatedQueueIds),
                        string.Join(",", c2AllocatedQueueIds),
                        string.Join(",", c3AllocatedQueueIds),
                        string.Join(",", c4AllocatedQueueIds)));
                    waitHandle.Set();
                }
            }, 1000, 1000);

            waitHandle.WaitOne();
            scheduleService.ShutdownTask(taskId);
        }
开发者ID:kouweizhong,项目名称:equeue,代码行数:33,代码来源:Program.cs


示例3: StartConsumers

        static void StartConsumers()
        {
            var messageHandler = new MessageHandler();

            //Start four consumers.
            var consumerSetting = new ConsumerSetting { HeartbeatBrokerInterval = 1000, UpdateTopicQueueCountInterval = 1000, RebalanceInterval = 1000 };
            var consumer1 = new Consumer("Consumer1", "group1", consumerSetting).Subscribe("SampleTopic").SetMessageHandler(messageHandler).Start();
            var consumer2 = new Consumer("Consumer2", "group1", consumerSetting).Subscribe("SampleTopic").SetMessageHandler(messageHandler).Start();
            var consumer3 = new Consumer("Consumer3", "group1", consumerSetting).Subscribe("SampleTopic").SetMessageHandler(messageHandler).Start();
            var consumer4 = new Consumer("Consumer4", "group1", consumerSetting).Subscribe("SampleTopic").SetMessageHandler(messageHandler).Start();

            //Below to wait for consumer balance.
            _logger.Info("Start consumer load balance, please wait for a moment.");
            var scheduleService = ObjectContainer.Resolve<IScheduleService>();
            var waitHandle = new ManualResetEvent(false);
            var taskId = scheduleService.ScheduleTask("WaitQueueAllocationComplete", () =>
            {
                var c1AllocatedQueueIds = consumer1.GetCurrentQueues().Select(x => x.QueueId);
                var c2AllocatedQueueIds = consumer2.GetCurrentQueues().Select(x => x.QueueId);
                var c3AllocatedQueueIds = consumer3.GetCurrentQueues().Select(x => x.QueueId);
                var c4AllocatedQueueIds = consumer4.GetCurrentQueues().Select(x => x.QueueId);
                if (c1AllocatedQueueIds.Count() == 1 && c2AllocatedQueueIds.Count() == 1 && c3AllocatedQueueIds.Count() == 1 && c4AllocatedQueueIds.Count() == 1)
                {
                    _logger.Info(string.Format("Consumer load balance finished. Queue allocation result: c1:{0}, c2:{1}, c3:{2}, c4:{3}",
                        string.Join(",", c1AllocatedQueueIds),
                        string.Join(",", c2AllocatedQueueIds),
                        string.Join(",", c3AllocatedQueueIds),
                        string.Join(",", c4AllocatedQueueIds)));
                    waitHandle.Set();
                }
            }, 1000, 1000);

            waitHandle.WaitOne();
            scheduleService.ShutdownTask(taskId);
        }
开发者ID:edgevagrant,项目名称:equeue,代码行数:35,代码来源:Program.cs


示例4: Subscribe

        public IDisposable Subscribe(MessageHandler messageHandler)
        {
            lock (_handlers)
            {
                _handlers.Add(messageHandler);
                _handlersSnapshot = _handlers.ToArray();

                if (_underlying == null)
                {
                    _underlying = OnRegister(message =>
                    {
                        lock (_handlers)
                        {
                            foreach (var handler in _handlersSnapshot)
                            {
                                handler(message);
                            }
                        }
                    });
                }
            }
            return new AnonymousDisposable(() =>
            {
                lock (_handlers)
                {
                    _handlers.Remove(messageHandler);
                    _handlersSnapshot = _handlers.ToArray();
                    if (_handlers.Count == 0)
                    {
                        _underlying.Dispose();
                        _underlying = null;
                    }
                }
            });
        }
开发者ID:AdaptiveConsulting,项目名称:ReactiveTraderCloud,代码行数:35,代码来源:SubscriberBase.cs


示例5: App

        public App()
            : base()
        {
            // create long-lived objects
            handler = new MOCKMessageHandler();
            player1Window = new MainWindow();
            player1Window.Title = "Player1";
            player2Window = new MainWindow();
            player2Window.Title = "Player2";
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);

            // wire up event handler
            player1Window.AddIPAddressMenuItemHandler(HandleIPAddressMenuItemForPlayer1);
            player2Window.AddIPAddressMenuItemHandler(HandleIPAddressMenuItemForPlayer2);
            player1Window.AddNameMenuItemHandler(HandleNameMenuItemForPlayer1);
            player2Window.AddNameMenuItemHandler(HandleNameMenuItemForPlayer2);
            player1Window.GameBoard.AddMouseHandler(HandleMouseEventForPlayer1);
            player2Window.GameBoard.AddMouseHandler(HandleMouseEventForPlayer2);

            // show the Views
            player1Window.Show();
            player2Window.Show();
            timer.Start();
        }
开发者ID:bdr27,项目名称:c-,代码行数:25,代码来源:App.xaml.cs


示例6: AddSessionHandler

 public void AddSessionHandler(SocketAsyncEventArgs e,NetInterface netif,MessageHandler handler)
 {
     long sessionID = Convert.ToInt64(e.UserToken);
     SessionHandler sh = new SessionHandler(sessionID,e, netif, handler);
     m_dicSessionHandler.Add(sessionID,sh);
     PushSessionBuffer(e);
 }
开发者ID:sysq,项目名称:SquirrelGameServer,代码行数:7,代码来源:SessionManager.cs


示例7: RemoveListener

 public static void RemoveListener(MessageHandler handler)
 {
     lock (s_mutex)
     {
         Message -= handler;
     }
 }
开发者ID:hellyhe,项目名称:pgina,代码行数:7,代码来源:InProcAppender.cs


示例8: ShellViewModel

		public ShellViewModel(IEventAggregator eventAggregator, MessageHandler messageHandler)
		{
			this.eventAggregator = eventAggregator;
			LogMessages = new BindableCollection<LogEntry>();

			ViewAttached += OnViewAttachedEventHandler;
		}
开发者ID:vcaraulean,项目名称:CaliburnMicro.AsyncDemo,代码行数:7,代码来源:ShellViewModel.cs


示例9: App

        public App()
            : base()
        {
            handler = new MOCKMessageHandler();
            handler.connectTo("127.0.0.1", 50000);
            //handler.sendRequest("SET_NAME,BrendanRusso");
            Debug.WriteLine(handler.getResponse());
            handler.sendRequest("PUT,BrendanRusso,3,1");
            Debug.WriteLine(handler.getResponse());

            player1Window = new MainWindow();
            player2Window = new MainWindow();

            player1Window.Title = "Player 1 Window";
            player2Window.Title = "Player 2 Window";

            player2Window.enableIpSet();

            //Wires handlers
            wireHandlers(player1Window);
            wireHandlers(player2Window);
            player1Window.AddSetNameMenuItemHandler(HandleSetNamePlayer1MenuItem);
            player2Window.AddSetNameMenuItemHandler(HandleSetNamePlayer2MenuItem);
            
            //player1Window.AddIPAddressMenuItemHandler(HandleIPAddressMenuItem);
            //player1Window.GameBoard.AddMouseHandler(HandleMouseEvent);

            player1Window.Show();
            player2Window.Show();                     
        }
开发者ID:bdr27,项目名称:c-,代码行数:30,代码来源:App.xaml.cs


示例10: ConnectionHandler

 public ConnectionHandler(Client mainForm)
 {
     this.mainForm = mainForm;
     ServerSocket = new TcpClient();
     messageHandler = new MessageHandler();
     PacketManager.DefineOpcodeHandlers();
 }
开发者ID:thebillkidy,项目名称:INF202A_DotNetDeel2,代码行数:7,代码来源:ConnectionHandler.cs


示例11: SessionHandler

 public SessionHandler(long sessionID, object sessionObject, NetInterface netIF,MessageHandler del)
 {
     m_sessionID = sessionID;
     m_sessionObject = sessionObject;
     m_interface = netIF;
     m_handler = del;
 }
开发者ID:sysq,项目名称:SquirrelGameServer,代码行数:7,代码来源:SessionHandler.cs


示例12: ConnectorConfig

 ConnectorConfig(MessageHandler handler)
 {
     m_bAutoReConnect = false;
     m_iAutoTime = 0;
     m_handler = handler;
     //m_Connectact = NULL;
 }
开发者ID:sysq,项目名称:SquirrelGameServer,代码行数:7,代码来源:CommonType.cs


示例13: AddListener

 public static void AddListener(MessageHandler handler)
 {
     lock (s_mutex)
     {
         Message += handler;
     }
 }
开发者ID:hellyhe,项目名称:pgina,代码行数:7,代码来源:InProcAppender.cs


示例14: Run_in_test

        public void Run_in_test()
        {
            var streamer = EnvelopeStreamer.CreateDefault(typeof(CreateCustomer), typeof(CustomerCreated));

            var builder = new CqrsEngineBuilder(streamer);
            var account = new MemoryAccount();

            var nuclear = account.CreateNuclear();
            var inbox = account.CreateInbox("input");
            var sender = account.CreateSimpleSender(streamer, "input");

            var handler = new MessageHandler();
            handler.WireToLambda<CreateCustomer>(customer => Consume(customer, nuclear, sender));
            handler.WireToLambda<CustomerCreated>(m => Console.WriteLine("Created!"));
            builder.Handle(inbox, handler.HandleEnvelope);

            using (var engine = builder.Build())
            {
                sender.SendOne(new CreateCustomer
                {
                    CustomerId = 1,
                    CustomerName = "Rinat Abdullin"
                });
                engine.RunForever();
            }
        }
开发者ID:ashic,项目名称:lokad-cqrs,代码行数:26,代码来源:Documentation_sample.cs


示例15: RegisterTriggerRule

 public static void RegisterTriggerRule(MessageHandler c, TestTriggerCondition f)
 {
     lock (hashMutex)
     {
         hash.Add(c, f);
     }
 }
开发者ID:dianatatu,项目名称:REACH,代码行数:7,代码来源:Commander.cs


示例16: BackgroundDispatchAndWait

		protected override void BackgroundDispatchAndWait (MessageHandler handler)
		{
			if (InvokeBackgroundDispatchAndWaitImmediately) {
				handler.Invoke ();
			} else {
				BackgroundDispatchersQueued.Add (handler);
			}
		}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:8,代码来源:TestableBackgroundPackageActionRunner.cs


示例17: AddHandler

 /// <summary>
 /// Add a new handler to the handler queue.
 /// </summary>
 /// <returns>A registration. Dispose to unregister.</returns>
 public IDisposable AddHandler(MessageHandler handler)
 {
     lock (handlersLock)
     {
         handlers.Add(handler);
         return new HandlerRegistration(this, handler);
     }
 }
开发者ID:chrissharp,项目名称:LoconetToolbox,代码行数:12,代码来源:LocoBuffer.cs


示例18: StartListening

 /// <summary>
 /// Start listening to run messages, returning the current list of messages.
 /// </summary>
 /// <param name="handler">The <see cref="MessageHandler" /> called when a message is added</param>
 /// <returns>The current list of messages</returns>
 public string[] StartListening( MessageHandler handler )
 {
     lock ( _alMessages )
     {
         Message += handler;
         return AllMessages;
     }
 }
开发者ID:ilya11211,项目名称:nprof,代码行数:13,代码来源:RunMessageCollection.cs


示例19: UnregisterTriggerRule

 public static void UnregisterTriggerRule(MessageHandler c, TestTriggerCondition f)
 {
     lock (hashMutex)
     {
         if (hash.ContainsKey(c) && hash[c] == f)
             hash.Remove(c);
     }
 }
开发者ID:dianatatu,项目名称:REACH,代码行数:8,代码来源:Commander.cs


示例20: On

        private void On(MessageHandler handler, string msg)
        {
            // check for subsriptions, if some, do some!
            if (handler != null)
                handler(this, msg);

            SimpleErrorLogger.Trace(msg);
        }
开发者ID:hoangtan,项目名称:PushSharp-Anywhere,代码行数:8,代码来源:PushNotificationProcessor.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MessageHeaders类代码示例发布时间:2022-05-24
下一篇:
C# MessageFlags类代码示例发布时间: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