本文整理汇总了C#中Thread.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.GetLength方法的具体用法?C# Thread.GetLength怎么用?C# Thread.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread.GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Using LAMX Distruptor .Net 2.x With WCF - Publisher");
Console.WriteLine();
Console.WriteLine("NOTE:Start the Consumer before starting the publisher!");
Console.WriteLine("Press <ENTER> to start Publisher.");
Console.ReadLine();
Console.WriteLine("Creating {0} Publishers...", Config.Test.MaxPublisers);
Thread[] publisherThreads = new Thread[Config.Test.MaxPublisers];
EventPublisher[] publishers = new EventPublisher[Config.Test.MaxPublisers];
Barrier syncPublisherStartBarrier = new Barrier(Config.Test.MaxPublisers);
for (Int16 i = 0; i < Config.Test.MaxPublisers; i++)
{
publishers[i] = new EventPublisher(i, Config.Test.EventsPerPublisher, syncPublisherStartBarrier);
}
for (Int16 i = 0; i < Config.Test.MaxPublisers-1; i++)
{
publisherThreads[i] = new Thread(publishers[i].Start);
publisherThreads[i].Name = String.Format("Publisher {0}", i);
publisherThreads[i].Start();
}
var stopwatch = Stopwatch.StartNew();
publishers[Config.Test.MaxPublisers - 1].Start();
if (publisherThreads.GetLength(0) > 1)
{
for (Int16 i = 0; i < Config.Test.MaxPublisers; i++)
{
if(publisherThreads[i]!=null)
publisherThreads[i].Join();
}
}
stopwatch.Stop();
var totalEventsPublished = Config.Test.MaxPublisers * Config.Test.EventsPerPublisher;
var eventsPublishedPerSecond = ( totalEventsPublished * 1000L) / stopwatch.ElapsedMilliseconds;
StringBuilder summaryBuilder = new StringBuilder();
summaryBuilder.AppendLine("\nEvent Publish Summary");
summaryBuilder.AppendLine("------------------------------------------------------------------------");
summaryBuilder.AppendFormat("Total Events Published\t:{0:###,###,###,###}\n", totalEventsPublished);
summaryBuilder.AppendFormat("Elapsed Duration(ms)\t:{0:###,###}\n", stopwatch.ElapsedMilliseconds);
summaryBuilder.AppendFormat("Throughput(Tps)\t\t:{0:###,###,###,###}", eventsPublishedPerSecond);
Log.Write(summaryBuilder.ToString());
Console.WriteLine("Press <ENTER> to exit.");
Console.ReadLine();
}