Example #1
0
        public override void Stop()
        {
            try {
                _shutdown = true;
                Util.Wake(this);
                if (_controller != null)
                {
                    _controller.Stop();
                }
                if (_primFactory != null)
                {
                    if (_clearCreated)
                    {
                        _primFactory.ClearCreated();
                    }
                    _primFactory.Shutdown();
                }
                if (_queueFactory != null && _stopQueues)
                {
                    _queueFactory.ShutdownAll();
                    Console.WriteLine(_queueFactory.Queues.Count + " Queues:");
                    foreach (IAsynchQueue q in _queueFactory.Queues)
                    {
                        Console.WriteLine("{0,-40} - Active: {1,7:0.###}% - Mean time per task: {2,8:0.###}ms - Helpers (Max: {3,2}, Tot: {4,6}) - {5,-40}" /* - Time: {6,-18} - Helper Time: {7,17}"*/,
                                          q.IsRunning ? q.Name : "(" + q.Name + ")",
                                          q.Statistics.PercentageActive,
                                          q.Statistics.MeanProcessTime,
                                          q.Statistics.MaxHelperThreads,
                                          q.Statistics.TotalHelpersSpawned,
                                          string.Format(q.Statistics.UnprocessedTasks > 0 || q.Statistics.FailedTasks > 0 ?
                                                        q.Statistics.FailedTasks > 0 ?
                                                        "# Tasks: {0,-6} - # Failed Tasks: {2}" :
                                                        "# Tasks: {0,-6} - # Unprocessed Tasks: {1}" :
                                                        "# Tasks: {0}",
                                                        q.Statistics.QueuedTasks,
                                                        q.Statistics.UnprocessedTasks,
                                                        q.Statistics.FailedTasks)/*,
                                                                                  * q.Statistics.Time,
                                                                                  * q.Statistics.TotalHelperTime*/
                                          );
                    }
                    foreach (var task in _queueFactory.Statistics.UnprocessedTaskNames)
                    {
                        Console.WriteLine(task);
                    }
                }
                if (Host.Object.Exists)
                {
                    Host.Object.Say(AppDomain.CurrentDomain.FriendlyName + " stopped.");
                }

                foreach (var pair in BindableWorld.CallCounts.OrderBy <KeyValuePair <string, int>, int>(pair => pair.Value))
                {
                    Console.WriteLine("World.{0,-50} Call Count: {1}", pair.Key, pair.Value);
                }
                foreach (var pair in BindableHost.CallCounts.OrderBy <KeyValuePair <string, int>, int>(pair => pair.Value))
                {
                    Console.WriteLine("Host.{0,-51} Call Count: {1}", pair.Key, pair.Value);
                }
                foreach (var pair in TrackedObjectAccessor.CallCounts.OrderBy <KeyValuePair <string, int>, int>(pair => pair.Value))
                {
                    Console.WriteLine("Object.{0,-49} Call Count: {1}", pair.Key, pair.Value);
                }
            } catch (Exception e) {
                Console.WriteLine(e + " \n\n " + e.StackTrace);
            }
        }