Exemplo n.º 1
0
        public void CheckCompletedTest()
        {
            var keys = new[] { "testkey1", "testkey2" };
            var vals = new[] { "1", "2" };

            RedisConnectionPool.SetExpire(keys, vals, 300);
            RedisConnectionPool.Process(c =>
            {
                var values = new List <string>();
                using (var p = c.CreatePipeline())
                {
                    foreach (var key in keys)
                    {
                        string k = key;
                        p.QueueCommand(cli => cli.Get <string>(k), v =>
                        {
                            values.Add(v);
                        });
                    }
                    p.Flush();
                }
                Trace.WriteLine(string.Join(",", values));
            });
            var watch = Stopwatch.StartNew();
            var data  = ShareCacheStruct.Get <ChildData>(1);

            data.Age++;
            bool result = CacheFactory.CheckCompleted();

            Trace.WriteLine("Queue result:" + result);
            WaitEnd(watch);
        }
Exemplo n.º 2
0
 private static void OnModelChangeBefore(Assembly assembly)
 {
     try
     {
         IsRunning = false;
         TraceLog.ReleaseWrite("Wait for the update before Model script...");
         CacheFactory.UpdateNotify(true);
         var task = System.Threading.Tasks.Task.Factory.StartNew(() =>
         {
             int time = CheckTimeout / 100;
             try
             {
                 while (time > 0 && !CacheFactory.CheckCompleted())
                 {
                     Thread.Sleep(100);
                     time--;
                 }
             }
             catch (Exception)
             {
             }
         });
         if (System.Threading.Tasks.Task.WaitAll(new[] { task }, CheckTimeout))
         {
             TraceLog.ReleaseWrite("Update before Model script OK.");
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("OnModelChangeBefore error:{0}", ex);
     }
 }
Exemplo n.º 3
0
 private static void OnModelChangeBefore(Assembly assembly)
 {
     try
     {
         Interlocked.Exchange(ref _isRunning, 0);
         TraceLog.ReleaseWrite("Wait for the update before Model script...");
         CacheFactory.UpdateNotify(true);
         var task = System.Threading.Tasks.Task.Factory.StartNew(() =>
         {
             try
             {
                 while (!CacheFactory.CheckCompleted())
                 {
                     Thread.Sleep(100);
                 }
             }
             catch (Exception)
             {
             }
         });
         System.Threading.Tasks.Task.WaitAll(task);
         TraceLog.ReleaseWrite("Update before Model script OK.");
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("OnModelChangeBefore error:{0}", ex);
     }
 }