예제 #1
0
        static void Main(string[] args)
        {
            Dictionary <int, ChainsAPM.Interfaces.ICommand <byte> > CommandList = new Dictionary <int, ICommand <byte> >();
            var cmd1 = new ChainsAPM.Commands.Common.SendString("");

            CommandList.Add(cmd1.Code, cmd1);
            CallContext.LogicalSetData("CommandProviders", CommandList);

            for (int i = 0; i < MAX; i++)
            {
                var whand = new System.Threading.ManualResetEventSlim();
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback((object o) =>
                {
                    var rand     = new Random();
                    var hostname = System.Configuration.ConfigurationManager.AppSettings["hostname"];
                    var port     = int.Parse(System.Configuration.ConfigurationManager.AppSettings["port"]);
                    System.Net.Sockets.TcpClient tcpC = new System.Net.Sockets.TcpClient(hostname, port);
                    TcpByteAgentHandler tcbah         = new TcpByteAgentHandler(new TcpByteTransport(tcpC), TcpByteAgentHandler.HandlerType.SendHeavy);
                    tcbah.AddCommand(new ChainsAPM.Commands.Common.SendString(""));
                    itemCounter.GetOrAdd(tcbah.GetHashCode(), System.Threading.Interlocked.Increment(ref counter2));
                    System.Threading.Interlocked.Increment(ref counter3);
                    tcbah.HasData      += tcbah_HasData;
                    tcbah.Disconnected += tcbah_Disconnected;

                    tcpC.NoDelay   = true;
                    int counter    = 0;
                    int msgCounter = 0;
                    int stopCount  = 10000;
                    do
                    {
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        msgCounter += 72;
                        System.Threading.Thread.Sleep(rand.Next(5, 25));
                    } while (++counter != stopCount);


                    Console.WriteLine("Messages Sent: {0}", msgCounter);
                    tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString("Done!"));
                    Console.WriteLine("Done Sent!");
                    lock (msgLock)
                    {
                        totalMessagesSent += msgCounter + 1;
                    }
                }));
            }
            waitHandl.Wait();
            Console.WriteLine("Messages Sent: {0}", totalMessagesSent);
        }
예제 #2
0
        static void tcbah_HasDataEvent(object sender)
        {
            var tcbah     = sender as TcpByteAgentHandler;
            var stringCmd = new ChainsAPM.Commands.Common.SendString("Done!");
            var arr       = tcbah.GetCommands();

            foreach (var item in arr)
            {
                System.Threading.Interlocked.Increment(ref messagesRecvd);
                if (item != null)
                {
                    if (item is ChainsAPM.Commands.Agent.DefineFunction)
                    {
                        var DefFunc = item as ChainsAPM.Commands.Agent.DefineFunction;
                        tcbah.FunctionList.Add(DefFunc.FunctionID, DefFunc.FunctionName);
                    }
                    if (item is ChainsAPM.Commands.Agent.AgentInformation)
                    {
                        tcbah.AgentInfo     = item as ChainsAPM.Commands.Agent.AgentInformation;
                        tcbah.ConnectedTime = DateTime.Now;
                        Console.WriteLine("Agent {0} connected with version {1} from machine {2}", ((ChainsAPM.Commands.Agent.AgentInformation)item).AgentName, ((ChainsAPM.Commands.Agent.AgentInformation)item).Version, ((ChainsAPM.Commands.Agent.AgentInformation)item).MachineName);
                        var okCmd = new ChainsAPM.Commands.Common.SendString("OK!");
                        tcbah.SendCommand(okCmd);
                    }
                    if (item is ChainsAPM.Commands.Agent.FunctionEnterQuick)
                    {
                        var feq = item as ChainsAPM.Commands.Agent.FunctionEnterQuick;
                        if (!tcbah.ThreadDepth.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadDepth.Add(feq.ThreadID, 0);
                        }

                        if (!tcbah.ThreadEntryPoint.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadEntryPoint.Add(feq.ThreadID, new List <Tuple <long, long> >());
                        }

                        tcbah.ThreadEntryPoint[feq.ThreadID].Add(new Tuple <long, long>(tcbah.ThreadDepth[feq.ThreadID], feq.FunctionID));
                        tcbah.ThreadDepth[feq.ThreadID]++;
                    }

                    if (item is ChainsAPM.Commands.Agent.FunctionTailQuick)
                    {
                        var feq = item as ChainsAPM.Commands.Agent.FunctionTailQuick;
                        if (!tcbah.ThreadDepth.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadDepth.Add(feq.ThreadID, 0);
                        }

                        if (tcbah.ThreadDepth[feq.ThreadID] > 0)
                        {
                            tcbah.ThreadDepth[feq.ThreadID]--;
                        }


                        if (!tcbah.ThreadEntryPoint.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadEntryPoint.Add(feq.ThreadID, new List <Tuple <long, long> >());
                        }

                        tcbah.ThreadEntryPoint[feq.ThreadID].Add(new Tuple <long, long>(tcbah.ThreadDepth[feq.ThreadID], feq.FunctionID));
                    }

                    if (item is ChainsAPM.Commands.Agent.FunctionLeaveQuick)
                    {
                        var feq = item as ChainsAPM.Commands.Agent.FunctionLeaveQuick;
                        if (!tcbah.ThreadDepth.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadDepth.Add(feq.ThreadID, 0);
                        }

                        if (tcbah.ThreadDepth[feq.ThreadID] > 0)
                        {
                            tcbah.ThreadDepth[feq.ThreadID]--;
                        }

                        if (!tcbah.ThreadEntryPoint.ContainsKey(feq.ThreadID))
                        {
                            tcbah.ThreadEntryPoint.Add(feq.ThreadID, new List <Tuple <long, long> >());
                        }

                        tcbah.ThreadEntryPoint[feq.ThreadID].Add(new Tuple <long, long>(tcbah.ThreadDepth[feq.ThreadID], feq.FunctionID));
                    }
                    if (item is ChainsAPM.Commands.Common.SendString)
                    {
                        var it = item as ChainsAPM.Commands.Common.SendString;
                        Console.WriteLine("Agent {0} has sent string {1}", tcbah.AgentInfo.AgentName, it.StringData);
                        if (((ChainsAPM.Commands.Common.SendString)item).StringData == "Done!")
                        {
                            tcbah.SendCommand(stringCmd);
                            tcbah.Dispose();
                        }
                    }
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            Dictionary <int, ChainsAPM.Interfaces.ICommand <byte> > CommandList = new Dictionary <int, ICommand <byte> >();
            var cmd1 = new ChainsAPM.Commands.Common.SendString("");
            var cmd2 = new ChainsAPM.Commands.Agent.FunctionEnterQuick(0, 0, 0);
            var cmd3 = new ChainsAPM.Commands.Agent.FunctionLeaveQuick(0, 0, 0);
            var cmd4 = new ChainsAPM.Commands.Agent.AgentInformation();
            var cmd5 = new ChainsAPM.Commands.Agent.FunctionTailQuick(0, 0, 0);
            var cmd6 = new ChainsAPM.Commands.Agent.DefineFunction(0, 0, "", 0);

            CommandList.Add(cmd1.Code, cmd1);
            CommandList.Add(cmd1.Code + 1, cmd1); // SendString handles Unicode and ASCII
            CommandList.Add(cmd2.Code, cmd2);
            CommandList.Add(cmd3.Code, cmd3);
            CommandList.Add(cmd4.Code, cmd4);
            CommandList.Add(cmd5.Code, cmd5);
            CommandList.Add(cmd6.Code, cmd6);
            CallContext.LogicalSetData("CommandProviders", CommandList);
            GC.RegisterForFullGCNotification(30, 50);
            System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;
            var timerCheck = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                Console.WriteLine("GC Notification thread started.");
                while (true)
                {
                    GCNotificationStatus s = GC.WaitForFullGCApproach();
                    if (s == GCNotificationStatus.Succeeded)
                    {
                        Console.WriteLine("GC Notification raised.");
                        foreach (var item in concurrentAgentHandlerList)
                        {
                            item.Value.PauseTimers();
                        }
                    }
                    else if (s == GCNotificationStatus.Canceled)
                    {
                        Console.WriteLine("GC Notification cancelled.");
                        break;
                    }
                    else
                    {
                        // This can occur if a timeout period
                        // is specified for WaitForFullGCApproach(Timeout)
                        // or WaitForFullGCComplete(Timeout)
                        // and the time out period has elapsed.
                        Console.WriteLine("GC Notification not applicable.");
                        break;
                    }

                    // Check for a notification of a completed collection.
                    s = GC.WaitForFullGCComplete(500);
                    if (s == GCNotificationStatus.Succeeded)
                    {
                        Console.WriteLine("Full GC Complete");
                        foreach (var item in concurrentAgentHandlerList)
                        {
                            item.Value.RestartTimers();
                        }
                    }
                    else if (s == GCNotificationStatus.Canceled)
                    {
                        Console.WriteLine("GC Notification cancelled.");
                        break;
                    }
                    else if (s == GCNotificationStatus.Timeout || s == GCNotificationStatus.NotApplicable)
                    {
                        foreach (var item in concurrentAgentHandlerList)
                        {
                            item.Value.RestartTimers();
                        }
                    }
                    else
                    {
                        // Could be a time out.
                        Console.WriteLine("GC Notification not applicable.");
                        break;
                    }


                    System.Threading.Thread.Sleep(500);
                    // FinalExit is set to true right before
                    // the main thread cancelled notification.
                }
            }));

            timerCheck.Name = "GC Notification Thread";
            //timerCheck.Start();
            System.Net.Sockets.TcpListener tcpListen = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, 8080);
            tcpListen.Start(200);
            //listenTimer = new System.Threading.Timer(TimerCallback, tcpListen, 0, 100);
            System.Threading.ThreadPool.QueueUserWorkItem(wCb, tcpListen);
            Console.WriteLine("Server started");
            Console.WriteLine("Listening on {0}", tcpListen.LocalEndpoint.ToString());
            while (true)
            {
                lock (lockConsole)
                {
                    Console.WriteLine("Current connected clients: {0}\t\tPackets: {1}", clientsConnected, messagesRecvd);
                }
                System.Threading.Thread.Sleep(1000);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Dictionary<int, ChainsAPM.Interfaces.ICommand<byte>> CommandList = new Dictionary<int, ICommand<byte>>();
            var cmd1 = new ChainsAPM.Commands.Common.SendString("");
            CommandList.Add(cmd1.Code, cmd1);
            CallContext.LogicalSetData("CommandProviders", CommandList);

            for (int i = 0; i < MAX; i++)
            {
                var whand = new System.Threading.ManualResetEventSlim();
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback((object o) =>
                {
                    var rand = new Random();
                    var hostname = System.Configuration.ConfigurationManager.AppSettings["hostname"];
                    var port = int.Parse(System.Configuration.ConfigurationManager.AppSettings["port"]);
                    System.Net.Sockets.TcpClient tcpC = new System.Net.Sockets.TcpClient(hostname, port);
                    TcpByteAgentHandler tcbah = new TcpByteAgentHandler(new TcpByteTransport(tcpC), TcpByteAgentHandler.HandlerType.SendHeavy);
                    tcbah.AddCommand(new ChainsAPM.Commands.Common.SendString(""));
                    itemCounter.GetOrAdd(tcbah.GetHashCode(), System.Threading.Interlocked.Increment(ref counter2));
                    System.Threading.Interlocked.Increment(ref counter3);
                    tcbah.HasData += tcbah_HasData;
                    tcbah.Disconnected += tcbah_Disconnected;

                    tcpC.NoDelay = true;
                    int counter = 0;
                    int msgCounter = 0;
                    int stopCount = 10000;
                    do
                    {
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(10, 100)));
                        tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString(randString(5, 1000)));
                        msgCounter += 72;
                        System.Threading.Thread.Sleep(rand.Next(5, 25));
                    } while (++counter != stopCount);

                    Console.WriteLine("Messages Sent: {0}", msgCounter);
                    tcbah.SendCommand(new ChainsAPM.Commands.Common.SendString("Done!"));
                    Console.WriteLine("Done Sent!");
                    lock (msgLock)
                    {
                        totalMessagesSent += msgCounter + 1;
                    }

                }));
            }
            waitHandl.Wait();
            Console.WriteLine("Messages Sent: {0}", totalMessagesSent);
        }