Ejemplo n.º 1
0
 private void Increment(object state)
 {
     _heartbeat.IncrementCount();
     if (RandomValueGenerator.GetRandomBool())
     {
         Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
     }
 }
Ejemplo n.º 2
0
 private void DoWork(Heartbeat heartbeat, long taskIndex, long finalTaskIndex)
 {
     heartbeat.IncrementCount();
     //fake work:
     if (RandomValueGenerator.GetRandomBool())
     {
         Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
     }
     if (taskIndex == finalTaskIndex)
     {
         heartbeat.SetComplete("RunCountAndTimer_NoHandler_WithTasks finished");
     }
 }
Ejemplo n.º 3
0
        private void DoWork(Heartbeat heartbeat, long taskIndex, long finalTaskIndex)
        {
            if (heartbeat == null)
            {
                Trace.WriteLine("Heartbeat is null");
            }

            heartbeat.IncrementCount();
            //fake work:
            if (RandomValueGenerator.GetRandomBool())
            {
                Thread.Sleep(RandomValueGenerator.GetRandomInt(100));
            }
            if (taskIndex == finalTaskIndex)
            {
                heartbeat.SetComplete("StubComponent.Process finished");
            }
        }
Ejemplo n.º 4
0
        public void RunCountAndTimer_NoHandler()
        {
            long   countInterval = 1000;
            long   countTo       = RandomValueGenerator.GetRandomInt(1000, 10000);
            double timerInterval = 800; //0.8 seconds
            var    runTime       = RandomValueGenerator.GetRandomInt(3 * 1000, 10 * 1000);
            var    heartbeat     = new hb.Heartbeat(this, countInterval, timerInterval);

            heartbeat.Start("RunCountAndTimer_NoHandler, countInterval: {0}, countTo: {1}, timerInterval: {2}, runTime: {3}"
                            .FormatWith(countInterval, countTo, timerInterval, runTime));
            for (int i = 0; i < countTo; i++)
            {
                heartbeat.IncrementCount();
                if (RandomValueGenerator.GetRandomBool())
                {
                    Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
                }
            }
            heartbeat.SetComplete("RunCountAndTimer_NoHandler finished");
        }
Ejemplo n.º 5
0
 public AbstractEmployee()
 {
     isAvailable = RandomValueGenerator.GetRandomBool(probability);
 }