コード例 #1
0
        public void TestSmartRunnerStrategyCatchInheritedException()
        {
            int i = 0;

            // SystemException is parent of NullReferenceException
            RunWithRetry.Run <SystemException>(
                () =>
            {
                i++;
                throw new NullReferenceException(i.ToString());
            }, 2, 0);

            Assert.AreEqual(2, i);
        }
コード例 #2
0
        public void TestTryToRunTwiceIfParamIsTwo()
        {
            int i = 0;

            RunWithRetry.Run <NullReferenceException>(
                () =>
            {
                i++;
                if (i == 1)
                {
                    throw new NullReferenceException();
                }
            }, 2, 0);

            Assert.AreEqual(2, i);
        }
コード例 #3
0
        public void TestSmartRunnerThrowExactlyThrowedException()
        {
            int i = 0;

            try
            {
                RunWithRetry.Run <NullReferenceException>(
                    () =>
                {
                    i++;
                    throw new NullReferenceException(i.ToString());
                }, 2, 0);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual(e.Message, "3");
            }

            Assert.AreEqual(3, i);
        }
コード例 #4
0
ファイル: FarmCaching.cs プロジェクト: yarivat/Admin
        public void ClearMachinesCache(string appName)
        {
            if (string.IsNullOrEmpty(appName))
            {
                return;
            }

            logger.Log("FarmNormal", null, transport.SubscriberID, null, 3, "Send Message for app " + appName);

            try
            {
                RunWithRetry.Run <PublishSyncTimeoutException>(
                    () =>
                {
                    this.transport.PublishSync(new FarmMessage {
                        AppName = appName, Time = DateTime.Now
                    });
                }, 3, 200);
            }
            catch (PublishSyncTimeoutException exception)
            {
                logger.Log("FarmNormal", null, transport.SubscriberID, exception, 1, "Publish failed for app " + appName);
            }
        }