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


C# ICommandService.Execute方法代码示例

本文整理汇总了C#中ICommandService.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandService.Execute方法的具体用法?C# ICommandService.Execute怎么用?C# ICommandService.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommandService的用法示例。


在下文中一共展示了ICommandService.Execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommandQueuePoller

        public static void CommandQueuePoller(ICommandService service)
        {
            //Trace.WriteLine("LogPoller has started -- seeing if there's anything in the queue for me!!");

            CloudQueueMessage msg = CommandQueue.GetMessage();
            if (msg == null)
            {
                //Trace.TraceInformation("COMMAND QUEUE nothing found - going back to sleep");
            }

            while (msg != null)
            {
                //do something
                string myMessage = msg.AsString;
                CommandQueue.DeleteMessage(msg);
                Trace.TraceInformation("Got message {0}", myMessage);

                //split the ID from the type -- first item is ID, second is type
                string[] messageParts = myMessage.Split(new char[] {':'}, StringSplitOptions.RemoveEmptyEntries);
                if (messageParts.Length!=2)
                {
                    Trace.TraceError("COMMAND QUEUE message improperly formed.  {0}", myMessage);
                    continue;
                }

                CloudBlockBlob theBlob = CommandBlobContainer.GetBlockBlobReference(messageParts[0]);
                Type commandType = Type.GetType(messageParts[1]);
                CommandBase theCommand = null;

                using (MemoryStream msBlob = new MemoryStream())
                {
                    byte[] logBytes = theBlob.DownloadByteArray();
                    msBlob.Write(logBytes, 0, logBytes.Length);
                    BinaryFormatter bf = new BinaryFormatter();
                    msBlob.Position = 0;
                    object theObject = bf.Deserialize(msBlob);
                    theCommand = Convert.ChangeType(theObject, commandType) as CommandBase;
                }

                if (theCommand != null)
                {
                    service.Execute(theCommand);
                }
                else
                {
                    Trace.TraceInformation("COMMAND BLOB Could not deserialize message from queue id {0}", myMessage);
                }

                msg = CommandQueue.GetMessage();
            }
        }
开发者ID:DavidHoerster,项目名称:BuzzyGo,代码行数:51,代码来源:CommandWorker.cs


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