• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Counter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Counter的典型用法代码示例。如果您正苦于以下问题:C# Counter类的具体用法?C# Counter怎么用?C# Counter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Counter类属于命名空间,在下文中一共展示了Counter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FakeCounterFixture

 public FakeCounterFixture(int input, int output)
 {
     m_dio = new DioCrossConnectFixture(input, output);
     m_allocated = true;
     m_source = new FakeCounterSource(m_dio.GetOutput());
     m_counter = new Counter(m_dio.GetInput());
 }
开发者ID:chopshop-166,项目名称:WPILib,代码行数:7,代码来源:FakeCounterFixture.cs


示例2: Print

 public virtual string Print(Counter counter)
 {
     _counter = counter;
     if (TryPrintFizzBuzz() || TryPrintBuzz())
         return _returnValue;
     return PrintFizz();
 }
开发者ID:mroed,项目名称:practice,代码行数:7,代码来源:FizzBuzzPrinter.cs


示例3: BecomeConsumer

        public async Task<StreamSubscriptionHandle<int>> BecomeConsumer(Guid streamId, string streamNamespace, string providerToUse)
        {
            logger.Info("BecomeConsumer");

            // new counter for this subscription
            var count = new Counter();
            var error = new Counter();

            // get stream
            IStreamProvider streamProvider = GetStreamProvider(providerToUse);
            var stream = streamProvider.GetStream<int>(streamId, streamNamespace);

            int countCapture = consumerCount;
            consumerCount++;
            // subscribe
            StreamSubscriptionHandle<int> handle = await stream.SubscribeAsync(
                (e, t) => OnNext(e, t, countCapture, count),
                e => OnError(e, countCapture, error));

            // track counter
            consumedMessageCounts.Add(handle, Tuple.Create(count,error));

            // return handle
            return handle;
        }
开发者ID:JackWangCUMT,项目名称:orleans,代码行数:25,代码来源:MultipleSubscriptionConsumerGrain.cs


示例4: Main

        static void Main(string[] args)
        {
            int pairs = args.Count() == 0 ? 16 : Int32.Parse(args[0]);
            int msgs = args.Count() == 2 ? Int32.Parse(args[1]) : 10;
            int sleepForMax = 20;

            var counters = new Counter[pairs];

            InitCounters(pairs, counters, msgs);

            int sleepFor = sleepForMax;
            while (sleepFor > 0)
            {
                Console.WriteLine("Sleeping for "+sleepFor+" seconds whilst it warms up");
                Thread.Sleep(1000);
                sleepFor--;
            }

            Console.WriteLine("Warm up sent "+ SumCounters(pairs,counters) + " messages. Running for real now...");
            ResetCounters(pairs, counters);

            Thread.Sleep(1000 * sleepForMax);

            shutdownAll();

            var sum = SumCounters(pairs, counters);

            Console.WriteLine("" + sum + " messages sent in "+ sleepForMax + " seconds.");

            decimal sps = ((decimal)sum) / ((decimal)sleepForMax);

            Console.WriteLine("That's " + sps + " messages per second");

            Console.ReadKey();
        }
开发者ID:plouh,项目名称:language-ext,代码行数:35,代码来源:Program.cs


示例5: DbConnectionPoolCounters

 protected DbConnectionPoolCounters(string categoryName, string categoryHelp)
 {
     AppDomain.CurrentDomain.DomainUnload += new EventHandler(this.UnloadEventHandler);
     AppDomain.CurrentDomain.ProcessExit += new EventHandler(this.ExitEventHandler);
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.ExceptionEventHandler);
     string instanceName = null;
     if (!System.Data.Common.ADP.IsEmpty(categoryName) && System.Data.Common.ADP.IsPlatformNT5)
     {
         instanceName = this.GetInstanceName();
     }
     string str2 = categoryName;
     this.HardConnectsPerSecond = new Counter(str2, instanceName, CreationData.HardConnectsPerSecond.CounterName, CreationData.HardConnectsPerSecond.CounterType);
     this.HardDisconnectsPerSecond = new Counter(str2, instanceName, CreationData.HardDisconnectsPerSecond.CounterName, CreationData.HardDisconnectsPerSecond.CounterType);
     this.NumberOfNonPooledConnections = new Counter(str2, instanceName, CreationData.NumberOfNonPooledConnections.CounterName, CreationData.NumberOfNonPooledConnections.CounterType);
     this.NumberOfPooledConnections = new Counter(str2, instanceName, CreationData.NumberOfPooledConnections.CounterName, CreationData.NumberOfPooledConnections.CounterType);
     this.NumberOfActiveConnectionPoolGroups = new Counter(str2, instanceName, CreationData.NumberOfActiveConnectionPoolGroups.CounterName, CreationData.NumberOfActiveConnectionPoolGroups.CounterType);
     this.NumberOfInactiveConnectionPoolGroups = new Counter(str2, instanceName, CreationData.NumberOfInactiveConnectionPoolGroups.CounterName, CreationData.NumberOfInactiveConnectionPoolGroups.CounterType);
     this.NumberOfActiveConnectionPools = new Counter(str2, instanceName, CreationData.NumberOfActiveConnectionPools.CounterName, CreationData.NumberOfActiveConnectionPools.CounterType);
     this.NumberOfInactiveConnectionPools = new Counter(str2, instanceName, CreationData.NumberOfInactiveConnectionPools.CounterName, CreationData.NumberOfInactiveConnectionPools.CounterType);
     this.NumberOfStasisConnections = new Counter(str2, instanceName, CreationData.NumberOfStasisConnections.CounterName, CreationData.NumberOfStasisConnections.CounterType);
     this.NumberOfReclaimedConnections = new Counter(str2, instanceName, CreationData.NumberOfReclaimedConnections.CounterName, CreationData.NumberOfReclaimedConnections.CounterType);
     string str3 = null;
     if (!System.Data.Common.ADP.IsEmpty(categoryName))
     {
         TraceSwitch switch2 = new TraceSwitch("ConnectionPoolPerformanceCounterDetail", "level of detail to track with connection pool performance counters");
         if (TraceLevel.Verbose == switch2.Level)
         {
             str3 = categoryName;
         }
     }
     this.SoftConnectsPerSecond = new Counter(str3, instanceName, CreationData.SoftConnectsPerSecond.CounterName, CreationData.SoftConnectsPerSecond.CounterType);
     this.SoftDisconnectsPerSecond = new Counter(str3, instanceName, CreationData.SoftDisconnectsPerSecond.CounterName, CreationData.SoftDisconnectsPerSecond.CounterType);
     this.NumberOfActiveConnections = new Counter(str3, instanceName, CreationData.NumberOfActiveConnections.CounterName, CreationData.NumberOfActiveConnections.CounterType);
     this.NumberOfFreeConnections = new Counter(str3, instanceName, CreationData.NumberOfFreeConnections.CounterName, CreationData.NumberOfFreeConnections.CounterType);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:DbConnectionPoolCounters.cs


示例6: CreateCounter

 private Counter CreateCounter()
 {
     Counter counter = new Counter();
     counter.Id = 1;
     counter.Name = "Foo";
     return counter;
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:7,代码来源:ProtobufSerializationTests.cs


示例7: ReadAreaType

        public static AreaType ReadAreaType(XmlReader reader, Counter<string> badTags)
        {
            string type = null;
            int level = 0;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "type")
                {
                    type = reader.ReadElementContentAsString();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "level")
                {
                    level = reader.ReadElementContentAsInt();
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    badTags.Increment(reader.Name);
                }
                else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "area")
                {
                    break;
                }
            }

            if (level == 0 || type == null)
                throw new Exception("Area type or level not specified.");
            return new AreaType(level, type);
        }
开发者ID:jennstubley,项目名称:rpg-game,代码行数:28,代码来源:XmlHelper.cs


示例8: FakeCounterFixture

 public FakeCounterFixture(int input, int output)
 {
     this.dio = new DIOCrossConnectFixture(input, output);
     m_allocated = true;
     source = new FakeCounterSource(dio.GetOutput());
     counter = new Counter(dio.GetInput());
 }
开发者ID:ThadHouse,项目名称:robotdotnet-wpilib,代码行数:7,代码来源:FakeCounterFixture.cs


示例9: SetUp

        public void SetUp(BenchmarkContext context)
        {
            _counter = context.GetCounter(CounterName);

            if (ConfigurationManager.AppSettings["TestKey"] != "42")
                throw new InvalidOperationException("TestKey from AppSettings could not be loaded!");
        }
开发者ID:petabridge,项目名称:NBench,代码行数:7,代码来源:ConfigBenchmark.cs


示例10: BecomeConsumer

        public async Task<StreamSubscriptionHandle<int>> BecomeConsumer(Guid streamId, string streamNamespace, string providerToUse)
        {
            logger.Info("BecomeConsumer");

            // new counter for this subscription
            var count = new Counter();

            // get stream
            IStreamProvider streamProvider = GetStreamProvider(providerToUse);
            var stream = streamProvider.GetStream<int>(streamId, streamNamespace);

            // subscribe
            StreamSubscriptionHandle<int> handle = await stream.SubscribeAsync(
                (e, t) =>
                {
                    logger.Info("Got next event {0}", e);
                    count.Increment();
                    return TaskDone.Done;
                });

            // track counter
            consumedMessageCounts.Add(handle, count);

            // return handle
            return handle;
        }
开发者ID:stanroze,项目名称:orleans,代码行数:26,代码来源:MultipleSubscriptionConsumerGrain.cs


示例11: Print

        public override string Print(Counter counter)
        {
            if (_counter == counter)
                return _expected;

            throw new InvalidOperationException();
        }
开发者ID:mroed,项目名称:practice,代码行数:7,代码来源:FizzBuzzPrinterFake.cs


示例12: Main

        static void Main(string[] args)
        {
            try {
            var face = new Face("aleph.ndn.ucla.edu");

            var counter = new Counter();

            // Try to fetch anything.
            var name1 = new Name("/");
            Console.Out.WriteLine("Express name " + name1.toUri());
            face.expressInterest(name1, counter, counter);

            // Try to fetch using a known name.
            var name2 = new Name("/ndn/edu/ucla/remap/demo/ndn-js-test/hello.txt/%FDU%8D%9DM");
            Console.Out.WriteLine("Express name " + name2.toUri());
            face.expressInterest(name2, counter, counter);

            // Expect this to time out.
            var name3 = new Name("/test/timeout");
            Console.Out.WriteLine("Express name " + name3.toUri());
            face.expressInterest(name3, counter, counter);

            // The main event loop.
            while (counter.callbackCount_ < 3) {
              face.processEvents();
              // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
              System.Threading.Thread.Sleep(5);
            }
              } catch (Exception e) {
            Console.Out.WriteLine("exception: " + e.Message);
              }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:test-get-async.cs


示例13: Main

    static void Main(string[] args)
    {
        Counter c = new Counter();
        c.ThresholdReached += c_ThresholdReached;

        // Provide remaining implementation for the class
    }
开发者ID:AlaminMahamud,项目名称:C-Sharp-Events,代码行数:7,代码来源:Handling+and+Raising+Events.cs


示例14: SetupClient

 protected override void SetupClient()
 {
     this.sendArgsPool = PrimitiveObjectPool.Create(100, CreateSendAsyncEventArgs);
     this.sentBytesCount = new Counter(MessageSize * MessageCount);
     this.clientSocket = new Socket(EndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     this.clientSocket.Connect(EndPoint);
 }
开发者ID:CaptainCodeman,项目名称:InfinityMQ,代码行数:7,代码来源:TcpSocketPubSubBaseline.cs


示例15: DeactivationTest_ClientConsumer

        public async Task DeactivationTest_ClientConsumer(Guid streamGuid, string streamNamespace)
        {
            // get producer and consumer
            var producer = GrainClient.GrainFactory.GetGrain<ISampleStreaming_ProducerGrain>(Guid.NewGuid());

            var count = new Counter();
            // get stream and subscribe
            IStreamProvider streamProvider = GrainClient.GetStreamProvider(streamProviderName);
            var stream = streamProvider.GetStream<int>(streamGuid, streamNamespace);
            StreamSubscriptionHandle<int> subscriptionHandle = await stream.SubscribeAsync((e, t) => count.Increment());

            // produce one message (PubSubRendezvousGrain will have one consumer and one producer)
            await producer.BecomeProducer(streamGuid, streamNamespace, streamProviderName);
            await producer.Produce();

            Assert.AreEqual(count.Value, 1, "Client consumer grain has not received stream message");

            //TODO: trigger deactivation programmatically
            await Task.Delay(TimeSpan.FromMilliseconds(130000)); // wait for the PubSubRendezvousGrain and the SampleStreaming_ProducerGrain to be deactivated

            // deactivating PubSubRendezvousGrain and SampleStreaming_ProducerGrain during the same GC cycle causes a deadlock
            // resume producing after the PubSubRendezvousGrain and the SampleStreaming_ProducerGrain grains have been deactivated:
            await producer.BecomeProducer(streamGuid, streamNamespace, streamProviderName).WithTimeout(Timeout, "BecomeProducer is hung due to deactivation deadlock");
            await producer.Produce().WithTimeout(Timeout, "Produce is hung due to deactivation deadlock");

            Assert.AreEqual(count.Value, 2, "Client consumer grain did not receive stream messages after PubSubRendezvousGrain and SampleStreaming_ProducerGrain reactivation");
        }
开发者ID:sbambach,项目名称:orleans,代码行数:27,代码来源:DeactivationTestRunner.cs


示例16: TestCounterInit1

 public void TestCounterInit1()
 {
     using (Counter ctr = new Counter())
     {
         TestInit(0, 0, 0, false, false, false, false);
     }
 }
开发者ID:ThadHouse,项目名称:robotdotnet-wpilib,代码行数:7,代码来源:TestCounter.cs


示例17: ForBreak

		public void ForBreak ()
		{
			var counter = new Counter ();

			var c = Expression.Parameter (typeof (Counter), "c");
			var l = Expression.Parameter (typeof (int), "l");

			var i = Expression.Variable (typeof (int), "i");
			var for_break = Expression.Label ("for_break");

			var hitcounter = Expression.Lambda<Action<Counter, int>> (
				CustomExpression.For (
					i,
					Expression.Constant (0),
					Expression.LessThan (i, l),
					Expression.PreIncrementAssign (i),
					Expression.Block (
						Expression.Condition (
							Expression.LessThan (i, Expression.Constant (10)),
							Expression.Call (c, typeof (Counter).GetMethod ("Hit", Type.EmptyTypes)),
							Expression.Goto (for_break))),
					for_break),
				c, l).Compile ();

			hitcounter (counter, 100);

			Assert.AreEqual (10, counter.Count);
		}
开发者ID:nordineb,项目名称:mono.linq.expressions,代码行数:28,代码来源:ForExpressionTest.cs


示例18: Add

 public Counter Add(string name, string notes, out int counterId)
 {
     var counter = new Counter(name, notes);
     counterId = _counters.Count;
     _counters.Add(counter);
     return counter;
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:Counters.cs


示例19: CreateSut

 private void CreateSut()
 {
     _counterMock = MockRepository.GenerateStrictMock<Counter>();
     _fizzPredicateMock = MockRepository.GenerateStrictMock<FizzPredicate>();
     _buzzPredicateMock = MockRepository.GenerateStrictMock<BuzzPredicate>();
     _sut = new FizzBuzzPrinter(_fizzPredicateMock, _buzzPredicateMock);
 }
开发者ID:mroed,项目名称:practice,代码行数:7,代码来源:When_Printing.cs


示例20: BecomeConsumer

        public async Task<StreamSubscriptionHandle<int>> BecomeConsumer(Guid streamId, string streamNamespace, string providerToUse)
        {
            logger.Info("BecomeConsumer");

            // new counter for this subscription
            var count = new Counter();

            // get stream
            IStreamProvider streamProvider = GetStreamProvider(providerToUse);
            var stream = streamProvider.GetStream<int>(streamId, streamNamespace);

            // subscribe
            StreamSubscriptionHandle<int> handle = await stream.SubscribeAsync(
                (e, t) =>
                {
                    logger.Info("Got next event {0}", e);
                    string contextValue = RequestContext.Get(SampleStreaming_ProducerGrain.RequestContextKey) as string;
                    if (!String.Equals(contextValue, SampleStreaming_ProducerGrain.RequestContextValue))
                    {
                        throw new Exception(String.Format("Got the wrong RequestContext value {0}.", contextValue));
                    }
                    count.Increment();
                    return TaskDone.Done;
                });

            // track counter
            consumedMessageCounts.Add(handle, count);

            // return handle
            return handle;
        }
开发者ID:uehara,项目名称:orleans,代码行数:31,代码来源:MultipleSubscriptionConsumerGrain.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CounterType类代码示例发布时间:2022-05-24
下一篇:
C# CouchbaseClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap