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


C# Worker.Work方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     using (var worker = new Worker("localhost", "console", "failing"))
     {
         worker.Work();
     }
 }
开发者ID:gsimoes,项目名称:resque-sharp,代码行数:7,代码来源:Program.cs

示例2: Send

    /// <summary>
    /// Synchronous send operation
    /// </summary>
    /// <param name="data">The data to send</param>
    /// <returns>The result of the send operation</returns>
    public ISendResult Send(MARC.Everest.Interfaces.IGraphable data)
    {
        // Good practice to check if the connector is open
        if (!IsOpen())
            throw new ConnectorException(ConnectorException.MSG_INVALID_STATE, ConnectorException.ReasonType.NotOpen, null);

        // Create a new worker
        Worker w = new Worker();

        // Always clone the current formatter
        w.Formatter = (IStructureFormatter)Formatter.Clone();

        // Perform the work
        w.Work(data);

        return w.Result;

    }
开发者ID:oneminot,项目名称:everest,代码行数:23,代码来源:MemoryConnector.cs

示例3: Receive

        public IReceiveResult Receive()
        {

            // Formatter check
            if (!IsOpen())
                throw new ConnectorException(ConnectorException.MSG_INVALID_STATE, ConnectorException.ReasonType.NotOpen);

            // Create the work that will perform the operations
            Worker w = new Worker();
            w.Formatter = (IStructureFormatter)this.Formatter.Clone();

            //TODO: Use a WaitHandle instead of Thread.Sleep()
            // If there is no data in the waiting data queue, block
            while (waitingData.Count == 0)
                Thread.Sleep(250);

            string state;
            lock (waitingData) { state = waitingData.Dequeue(); }
            w.Work(state);

            // Delete this file
            if (!keepFiles)
                try
                {
                    System.IO.File.Delete(w.Result.FileName);
                }
                catch (Exception) { } // Don't care if file delete fails


            // Return the result
            return w.Result;
        }
开发者ID:oneminot,项目名称:everest,代码行数:32,代码来源:FileListenConnector.cs

示例4: Send

        /// <summary>
        /// Publish a message to the currently opened queue
        /// </summary>
        /// <param name="data">The data to publish to the queue</param>
        /// <returns>A <see cref="ISendResult"/> structure representing the result of the send operation </returns>
        public ISendResult Send(MARC.Everest.Interfaces.IGraphable data)
        {
            if (!IsOpen())
                throw new ConnectorException(ConnectorException.MSG_INVALID_STATE, ConnectorException.ReasonType.NotOpen);

            // Send
            Worker w = new Worker();
            w.Formatter = Formatter.Clone() as IStructureFormatter;
            w.Queue = queue;

            // Perform the work
            w.Work(data);

            return w.Result;
        }
开发者ID:oneminot,项目名称:everest,代码行数:20,代码来源:MsmqPublishConnector.cs

示例5: Send

        /// <summary>
        /// Send the structure <paramref name="data"/> to the file system.
        /// </summary>
        /// <param name="data">The <see cref="MARC.Everest.Interfaces.IGraphable"/> data to be sent.</param>
        /// <returns>The result of the send operation.</returns>
        /// <example>
        /// Get the result of a send operation
        /// <code>
        /// FileSendResult result = conn.Send(instance);
        /// if(result.Code != ResultCode.Accepted) // Result was not successful
        ///     foreach(IResultDetail dtl in result.Details)
        ///         Console.WriteLine(dtl.Message);
        ///         </code>
        /// </example>
        /// <seealso cref="BeginSend"/>
        public ISendResult Send(MARC.Everest.Interfaces.IGraphable data)
        {
            if (!IsOpen())
                throw new ConnectorException(ConnectorException.MSG_INVALID_STATE, ConnectorException.ReasonType.NotOpen);

            // Setup the Worker
            Worker w = new Worker();
            w.Formatter = (IStructureFormatter)this.Formatter.Clone();
            w.TargetFile = GenerateTargetFile(data);
            w.Work(data);
            
            return w.Result;
        }
开发者ID:oneminot,项目名称:everest,代码行数:28,代码来源:FilePublishConnector.cs

示例6: Manage

 public void Manage()
 {
     var worker = new Worker();
     worker.Work();
 }
开发者ID:Alex223124,项目名称:High-Quality-Code,代码行数:5,代码来源:Manager.cs


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