コード例 #1
0
        public void TestPFEmailMq()
        {
            var resMsg = "";

            var p = new PagingParameters();

            p["backupDatabase"] = "bonus";

            TestPFEmailMqConsumer tmpObj = new TestPFEmailMqConsumer();

            PFMqHelper.BuildConsumer(tmpObj);
            Thread.Sleep(2000);//不延迟的话,后面太快了,前面还没开始监听

            var st      = DateTime.Now;
            var message = JsonConvert.SerializeObject(p);
            var t       = PFMqHelper.BuildProducer(message,
                                                   new TestPFEmailMqProducer());

            t.Wait();
            var et = DateTime.Now;

            resMsg = t.Result.Body;

            var usedTime = PFDataHelper.GetTimeSpan(et - st);//平均6秒

            Assert.IsTrue(resMsg == JsonConvert.SerializeObject("接收到信息:" + message));
            //Assert.IsTrue(true);
        }
コード例 #2
0
 private async Task TestAsync()
 {
     await Task.Run(() =>
     {
         var t = PFDataHelper.CountTime(() =>
         {
             Thread.Sleep(5000);
         });
         AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t)));
     });
 }
コード例 #3
0
        private Task TestTask()
        {
            var rt = new Task(() =>
            {
                var t = PFDataHelper.CountTime(() =>
                {
                    Thread.Sleep(5000);
                });
                AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t)));
            });

            rt.Start();
            return(rt);
        }
コード例 #4
0
        private async Task <bool> IsTestAsync()
        {
            var b = false;
            await Task.Run(() =>
            {
                var t = PFDataHelper.CountTime(() =>
                {
                    Thread.Sleep(5000);
                });
                AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t)));
                b = true;
            });

            return(b);
        }