本文整理汇总了C#中IQueue.TryDequeue方法的典型用法代码示例。如果您正苦于以下问题:C# IQueue.TryDequeue方法的具体用法?C# IQueue.TryDequeue怎么用?C# IQueue.TryDequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueue
的用法示例。
在下文中一共展示了IQueue.TryDequeue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandSender
static void CommandSender(IQueue Messagebox)
{
int sleepPeriod = 150;
string QueuedData;
MessageSender sender = new MessageSender(
Properties.NetworkSettings.Default.OperatorCommandsPort,
Messagebox,
Properties.NetworkSettings.Default.OperatorIPAddress);
while (true)
{
if (Messagebox.TryDequeue(out QueuedData))
{
sender.Send(QueuedData); //Default implementation which doesn't store state
}
Thread.Sleep(sleepPeriod);
}
}
示例2: Dispatcher
static void Dispatcher(IQueue MessageBox)
{
int sleepPeriod = 100;
CommandFactory factory = new CommandFactory();
string unparsedCommand = "";
while (true)
{
if (MessageBox.TryDequeue(out unparsedCommand))
{
ICommand command = factory.CreateCommand(unparsedCommand);
command.Execute();
}
else
{
Thread.Sleep(sleepPeriod);
}
//Thread.Sleep(sleepPeriod);
}
}
示例3: RemoveFromQueue
public string RemoveFromQueue(IQueue queue)
{
string result = null;
queue.TryDequeue(out result);
return result;
}
示例4: StatusUpdater
static void StatusUpdater(IQueue SerialStatusUpdaterMessageBox)
{
Dictionary<string, ISensorLog> latestSensorData = new Dictionary<string, ISensorLog>();
Initialize(latestSensorData); // initialize dictionary to set expected values
//GPSLog gps = new GPSLog("G123,456,789");
string banana;
ISensorLog sensorlog;
while (true)
{
while (SerialStatusUpdaterMessageBox.TryDequeue(out banana))
{
if (banana[0] == 'G') //perhaps put all of this into a factory
{
sensorlog = new GPSLog(banana);
}
else
{
sensorlog = new GPSLog("G9,999,999");
//do nothing for now
}
latestSensorData[sensorlog.Identifier] = sensorlog;
}
// Console.WriteLine(banana);
// gps.UpdateValues();
Thread.Sleep(200);
}
}