void Timer_Tick_DynamicDataUpdate(object state)
        {
            try
            {
                bool CarpoolingEnabled               = bool.Parse(ConfigurationManager.AppSettings["CarpoolingEnabled"]);
                bool TrafficEnabled                  = bool.Parse(ConfigurationManager.AppSettings["TrafficEnabled"]);
                DynamicDataVersion DynamicData       = new DynamicDataVersion {
                };
                CarPoolerDataVersioned CarPoolingTmp = new CarPoolerDataVersioned {
                };
                TrafficDataVersioned TrafficTmp      = new TrafficDataVersioned {
                };

                /* Get the dynamic data version from the backend web service */
                DynamicData = HTTPRequests.getDynamicDataVersionFromBackend(productionRoutingNetwork.MinPoint, productionRoutingNetwork.MaxPoint);

                if (DynamicData != null)
                {
                    if (CarpoolingEnabled)
                    {
                        /* Carpooling data version */
                        CarPoolingTmp.Version = new CarpoolerVersion(DynamicData.sites.First().carpooling_info.version,
                                                                     DynamicData.sites.First().carpooling_info.updated,
                                                                     DynamicData.sites.First().name,
                                                                     DynamicData.sites.First().carpooling_info.nightly_version,
                                                                     DynamicData.sites.First().carpooling_info.nightly_updated);
                        /* Update the carpooling network */
                        updateCarpoolingNetwork(CarPoolingTmp);
                    }

                    if (TrafficEnabled)
                    {
                        /* Traffic data version */
                        TrafficTmp.Version = new TrafficVersion(DynamicData.sites.First().reports_info.version,
                                                                DynamicData.sites.First().reports_info.updated,
                                                                DynamicData.sites.First().name);
                        /* Update the traffic network */
                        updateTrafficNetwork(TrafficTmp);
                    }
                }
            }
            finally
            {
                m_Timer.Change(DynamicDataIntervalTimeRequest, 0);
            }
        }
        void updateTrafficNetwork(TrafficDataVersioned TrafficTmp)
        {
            TrafficParser TParserTmp = null;

            //Just for testing: simulate a new data version
            //TrafficTmp.Version.version++;

            if ((Program.Traffic.Version != null) && (TrafficTmp.Version != null) &&
                (TrafficTmp.Version.version != Program.Traffic.Version.version))
            {
                log.Info("New Traffic data are available (prevVersion:" + Program.Traffic.Version.version + ", newVersion:" + TrafficTmp.Version.version + ")");

                /* Get the traffic reports from the backend web service */
                TrafficTmp.TrafficReport = HTTPRequests.getTrafficDataFromBackend(productionRoutingNetwork.MinPoint, productionRoutingNetwork.MaxPoint, productionRoutingNetwork.TrafficPropagationMaxDistance);

                /* Get differences between the old version and the new one */
                TrafficDiff TrafficDiff = TrafficParser.checkDifferences(Program.Traffic.TrafficReport, TrafficTmp.TrafficReport);

                if ((TrafficDiff.ElementsToRemove.Count > 0) || (TrafficDiff.ElementsToAdd.Count > 0))
                {
                    /* Update the network only when there are no pending threads (Monitor.Wait) */
                    lock (_ActiveWorkersLock)
                    {
                        while (_CountOfActiveWorkers > 0)
                        {
                            Monitor.Wait(_ActiveWorkersLock);
                        }

                        log.Info("Updating the production network with the traffic reports");

                        /* Remove the OLD Traffic reports from the network */
                        if (TrafficDiff.ElementsToRemove.Count > 0)
                        {
                            log.Info("Removing " + TrafficDiff.ElementsToRemove.Count + " deleted traffic reports from the processNetwork");
                            int i = 1;
                            foreach (TrafficReport el in TrafficDiff.ElementsToRemove)
                            {
                                productionRoutingNetwork.RemoveTrafficReport(el);

                                /* Update the original TrafficParser */
                                Program.TParser.TrafficReport.Remove(el);
                                i++;
                            }

                            log.Info("ProcessNetwork updated! (" + TrafficDiff.ElementsToRemove.Count + " old traffic reports deleted)");

                            /* Force the network update before processing the next request */
                            updateRN = true;
                        }

                        /* Add the NEW Traffic reports to the network */
                        if (TrafficDiff.ElementsToAdd.Count > 0)
                        {
                            /* Add to each connection the traffic report */
                            log.Info("Adding the new " + TrafficDiff.ElementsToAdd.Count + " traffic connections to the processNetwork");
                            TParserTmp = new TrafficParser(productionRoutingNetwork, TrafficDiff.ElementsToAdd);
                            TParserTmp.UpdateNetworkWithTrafficReport();

                            /* Update the original TParser and Traffic report classes */
                            foreach (TrafficReport el in TrafficDiff.ElementsToAdd)
                            {
                                Program.TParser.TrafficReport.Add(el);
                            }

                            log.Info("Processnetwork updated! (" + TrafficDiff.ElementsToAdd.Count + " new traffic reports added)");

                            /* Force the network update before processing the next request */
                            updateRN = true;
                        }

                        log.Info("Production network updated with the traffic reports");
                    }
                }


                /* If there are no modifications too, just update the version number (this happens for example if the driver quickly
                 * enable and disable a ride, so the version number changes but the content doesn't)
                 */
                /* Update the traffic report version */
                Program.Traffic.Version = new TrafficVersion(TrafficTmp.Version.version, TrafficTmp.Version.timestampVersion, TrafficTmp.Version.nameSite);
            }

            else
            {
                if (TrafficTmp.Version != null)
                {
                    //log.Info("Traffic version not changed: version=" + TrafficTmp.Version.version + " timestamp=" + TrafficTmp.Version.timestampVersion);
                }
            }
        }