示例#1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && cluster != null)
     {
         cluster.Dispose();
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            var tf    = new TaskFactory(ct);
            var s     = tf.StartNew(StoreData, ct);
            var f     = tf.StartNew(FetchData, ct);
            var fsi   = tf.StartNew(FetchServerInfo, ct);
            var tasks = new[] { s, f, fsi };

            Console.WriteLine("Hit any key to stop.");
            Console.ReadLine();
            cts.Cancel();

            try
            {
                Task.WaitAll(tasks);
            }
            catch (AggregateException ex)
            {
                foreach (var iex in ex.InnerExceptions)
                {
                    var msg = string.Format("[ChaosMonkeyApp] tasks canceled (ex: {0})", iex.Message);
                    Console.WriteLine(msg);
                }
            }
            catch (TaskCanceledException ex)
            {
                var msg = string.Format("[ChaosMonkeyApp] tasks canceled (ex: {0})", ex.Message);
                Console.WriteLine(msg);
            }

            cluster.Dispose();
            cts.Dispose();
            Console.WriteLine("Stopped.");
        }
示例#3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && endpoint != null)
     {
         endpoint.Dispose();
     }
 }