internal void ScheduleConnectionTaskToAPublication(string PublicationName, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                //this function is intended to be used by subscribers clients
                try
                {
                    if (!this._tableOfConnectionRegistersForScheduledConnectionTasks.ContainsKey(PublicationName))
                    {
                        string msg = "";
                        msg = "Task to connect with publication \'" + PublicationName + "\' was scheduled and started";
                        CustomEventLog.WriteEntry(EventLogEntryType.Information, msg);

                        PublicationConnectionTaskInfo reg = new PublicationConnectionTaskInfo(DPE_PublicationConnectionHandler_Type.subscriptorHandler, PublicationName, connectionMode);
                        lock (this._tableOfConnectionRegistersForScheduledConnectionTasks)
                        {
                            this._tableOfConnectionRegistersForScheduledConnectionTasks.Add(PublicationName, reg);
                        }
                        lock (this._queueOfScheduledConnectionTasks)
                        {
                            this._queueOfScheduledConnectionTasks.Enqueue(reg);
                        }

                        if (this._publicationsConnectionThread == null)
                        {
                            this._publicationsConnectionThread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadedFcn_ConnectionToEnqueuedDataPublications));
                            this._publicationsConnectionThread.IsBackground = true;
                            this._publicationsConnectionThread.Priority     = System.Threading.ThreadPriority.Normal;
                            this._publicationsConnectionThread.Start();
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
            internal void ThreadedFcn_ConnectionToEnqueuedDataPublications()
            {
                PublicationConnectionTaskInfo reg = null;
                bool continueCycle = true;

                while (continueCycle)
                {
                    try
                    {
                        //if there are connection registers
                        if (this._queueOfScheduledConnectionTasks.Count > 0)
                        {
                            //if the client is connected then performs connections

                            if (this._STXDataSocketClient.IsConnected)
                            {
                                lock (this._queueOfScheduledConnectionTasks)
                                {
                                    reg = (PublicationConnectionTaskInfo)this._queueOfScheduledConnectionTasks.Dequeue();
                                }

                                if (!(reg == null))
                                {
                                    try
                                    {
                                        this.ConnectoToPublication(reg.connectionType, reg.publicationName, reg.connectionMode);


                                        string msg = "";

                                        msg = "Connection with publication \'" + reg.publicationName + "\' was Performed succesfully";
                                        CustomEventLog.DisplayEvent(EventLogEntryType.SuccessAudit, msg);

                                        lock (this._tableOfConnectionRegistersForScheduledConnectionTasks)
                                        {
                                            this._tableOfConnectionRegistersForScheduledConnectionTasks.Remove(reg.publicationName);
                                        }

                                        reg.keepScheduledConnectionTask = false;
                                    }
                                    catch (Exception ex)
                                    {
                                        if (reg.GetElapsedTimeInSeconds() > MAX_CONNECTION_ELAPSED_SECONDS_AFTER_THROW_ERROR)
                                        {
                                            CustomEventLog.DisplayEvent(EventLogEntryType.Error, "Error connecting to publication \'" + reg.publicationName + "\' : " + ex.Message);
                                            reg.ResetTime();
                                        }


                                        //the connection failed and then the connection attempt is enqueed again only it theres is a record on the schedule table
                                        //that indicates that is pending to conenct to such publication

                                        lock (this._tableOfConnectionRegistersForScheduledConnectionTasks)
                                        {
                                            if (this._tableOfConnectionRegistersForScheduledConnectionTasks.ContainsKey(reg.publicationName))
                                            {
                                                lock (this._queueOfScheduledConnectionTasks)
                                                {
                                                    this._queueOfScheduledConnectionTasks.Enqueue(reg);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        CustomEventLog.DisplayEvent(EventLogEntryType.Error, ex.ToString());
                    }
                    finally
                    {
                        if (this._tableOfConnectionRegistersForScheduledConnectionTasks.Count == 0)
                        {
                            this._publicationsConnectionThread = null;
                            continueCycle = false;
                        }
                        else
                        {
                            if (this._STXDataSocketClient.IsConnected)
                            {
                                //is sleeps for 250 ms after attempt to connecto to another publication if the client is connected
                                System.Threading.Thread.Sleep(250);
                            }
                            else
                            {
                                //if the connection with the server is broken then waits a little bit more to attempt to connect to a publication
                                System.Threading.Thread.Sleep(2000);
                            }
                        }
                    }
                }
            }