/// <summary>
 /// Stops the agent.
 /// </summary>
 public void StopSession()
 {
     if (queueManager != null)
     {
         queueManager.Dispose();
         queueManager = null;
     }
     state = BatchingLogAgentStates.Disabled;
 }
        /// <summary>
        /// Used to spin up the agent.
        /// </summary>
        /// <returns>Indicates success</returns>
        public bool StartSession()
        {
            if (state == BatchingLogAgentStates.Enabled)
                throw new Exception("Session is already started");

            // load the config file
            if (Configuration == null)
                LoadConfig();

            try
            {
                if (Configuration.LoggingEnabled)
                {
                    // initialize new queue manager
                    queueManager = new QueueManager(this);
                    queueManager.BatchSending += queueManager_BatchSending;
                    queueManager.BatchSendSuccess += queueManager_BatchSendSuccess;
                    queueManager.BatchSendFailed += queueManager_BatchSendFailed;

                    // set SessionId & StartTime
                    SessionId = Guid.NewGuid();
                    SessionStartTime = DateTime.Now;

                    // enable logging
                    state = BatchingLogAgentStates.Enabled;
                }
                else
                    state = BatchingLogAgentStates.Disabled;

                return true;
            }
            catch (Exception ex)
            {
                BroadcastException(ex);
                state = BatchingLogAgentStates.Disabled;
                return false;
            }
        }