本文整理汇总了C#中QueueManager.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# QueueManager.Flush方法的具体用法?C# QueueManager.Flush怎么用?C# QueueManager.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueManager
的用法示例。
在下文中一共展示了QueueManager.Flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueueManager_EnqueTest
public void QueueManager_EnqueTest()
{
//Init
var qn = "q1";
var q = new QueueManager<string>(qn);
q.Flush();
// Push items into queue
data.ForEach(x => q.Push(x));
// Test
Assert.AreEqual(q.GetElements().Length, data.Count);
}
示例2: Main
static void Main(string[] args)
{
BootstrapManager.InitLogging();
BootstrapManager.BootRedis();
var queueManager = new QueueManager<Job>("urn:company:product:module:function");
queueManager.Flush();
queueManager.SubscribeForNewItem(
job => job.DoWork()
);
Console.WriteLine("Press ENTER to stop serving...");
Console.Read();
}
示例3: Test_Multiple_Push_And_Pop
public void Test_Multiple_Push_And_Pop()
{
int count = 100;
var qn = "q1";
var q = new QueueManager<string>(qn);
q.Flush();
for (int i = 0; i < count; i++)
{
q.Push(i.ToString());
}
for (int i = 0; i < count; i++)
{
var p = q.Pop();
Assert.AreEqual(int.Parse(p), i);
}
}
示例4: Queue_Enque_Pop_Test
public void Queue_Enque_Pop_Test()
{
// Init
var qn = "q1";
var q = new QueueManager<string>(qn);
q.Flush();
// Push items into queue q1
data.ForEach(x => q.Push(x));
// Pop and test
Assert.AreEqual(q.Pop(), data.First());
}
示例5: Test_Queue_Notifications_Concurrency
public void Test_Queue_Notifications_Concurrency()
{
int count = 100;
var qn = "q1";
var cq1 = new QueueManager<string>(qn);
var cq2 = new QueueManager<string>(qn);
var incomingMessages1 = new List<string>();
var incomingMessages2 = new List<string>();
cq1.Flush();
cq2.Flush();
cq1.SubscribeForNewItem(x => {
incomingMessages1.Add(x);
Log.Debug("Incoming item cq1 Value:" + x);
});
cq2.SubscribeForNewItem(x =>
{
incomingMessages2.Add(x);
Log.Debug("Incoming item cq2 Value:" + x);
});
int xx = 0;
for (int i = 0; i < count; i++)
{
Task.Factory.StartNew(() => {
int item = xx++;
Log.Debug("New Push:" + item.ToString() + " Thread:" + Thread.CurrentThread.ManagedThreadId);
cq1.Push(item.ToString(), true);
});
}
Log.Debug("Waiting...");
Thread.Sleep(2000);
Assert.AreEqual(incomingMessages1.Count + incomingMessages2.Count, count);
Log.Debug("Check if the queues are empty.");
var p1 = cq1.Pop();
Assert.IsNull(p1);
Log.Debug("Done!");
}