本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例6: Manage
public void Manage()
{
var worker = new Worker();
worker.Work();
}