private async void DoUpdate()
        {
            AddLog("Enter Update Thread");
            m_UpdateThread = Thread.CurrentThread;
            FtpServer.Instance.NewDataConnection    += FtpServer_NewDataConnection;
            FtpServer.Instance.ClosedDataConnection += FtpServer_ClosedDataConnection;
            FtpServer.Instance.SentData             += FtpServer_SentData;

            string pkgFilePath = ExportAddressBookUclPkg();//ExportAddressBookPkg();

            for (int i = 0; i < m_Devices.Count();)
            {
                lock (m_FtpTransferStatus)
                {
                    if (m_FtpTransferStatus.Count() >= 5)
                    {
                        List <FtpTransferStatus> toBeRemoved = new List <FtpTransferStatus>();
                        foreach (var status in m_FtpTransferStatus)
                        {
                            if (status.Status != FtpTransferStatus.STATUS.LOAD_ING)
                            {
                                toBeRemoved.Add(status);
                            }
                        }

                        foreach (var status in toBeRemoved)
                        {
                            m_FtpTransferStatus.Remove(status);
                        }
                    }

                    if (m_FtpTransferStatus.Count() >= 5)
                    {
                        continue;
                    }
                }

                Device Device = m_Devices[i];
                //AddLog(string.Format("Generate XML File for ({0}:{1})", Device.roomid, Device.ip));
                //string TempFolderPath = Path.GetCardListTempFolderPath(Device.roomid);
                //GenerateXmlFile(Device, TempFolderPath + @"\cardlist.xml");
                //string pkgFilePath = Path.GetCardListFolderRelativePath(Device.roomid) + @"\CARD.PKG";
                //PkgTool.ToPkgFile(TempFolderPath, Path.GetCardListFolderPath(Device.roomid) + @"\CARD.PKG");
                AddLog(string.Format("HTTP ({0}): Sending Upgrade Command", Device.ip));

                FtpTransferStatus transferStatus = new FtpTransferStatus(Device, i, pkgFilePath);
                //string uri = string.Format("http://{0}/dev/info.cgi?action=upgrade_addressbook&url=ftp://{1}/{2}",
                //    Device.ip, Config.Instance.LocalIP, pkgFilePath.Replace(@"\", "/"));
                //System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                //client.Timeout = new TimeSpan(0, 0, 1);
                var result = await ICMServer.Net.HttpClient.SendAddressBookUpgradeNotification(Device.ip, Config.Instance.LocalIP, pkgFilePath);

                try
                {
                    if (result)
                    {
                        AddLog(string.Format("HTTP ({0}): Send Upgrade success!", Device.ip));
                        SetStatusColumnText(i, "0%", Color.Black);  // TODO: Progress bar
                    }
                    else
                    {
                        transferStatus.Status = FtpTransferStatus.STATUS.LOAD_ERROR;
                        AddLog(string.Format("HTTP ({0}): Send Upgrade fail!", Device.ip));
                        SetStatusColumnText(i, "send upgrade command fail!", Color.Red);
                    }
                }
                catch (Exception) { }

                lock (m_FtpTransferStatus)
                {
                    m_FtpTransferStatus.Add(transferStatus);
                }
                ++i;
            }
            AddLog("Leave Update Thread");
        }
        private async void DoUpdate()
        {
            AddLog("Enter Update Thread");
            m_UpdateThread = Thread.CurrentThread;
            FtpServer.Instance.NewDataConnection    += FtpServer_NewDataConnection;
            FtpServer.Instance.ClosedDataConnection += FtpServer_ClosedDataConnection;
            FtpServer.Instance.SentData             += FtpServer_SentData;

            for (int i = 0; i < m_Devices.Count();)
            {
                lock (m_FtpTransferStatus)
                {
                    if (m_FtpTransferStatus.Count() >= 5)
                    {
                        List <FtpTransferStatus> toBeRemoved = new List <FtpTransferStatus>();
                        foreach (var status in m_FtpTransferStatus)
                        {
                            if (status.Status != FtpTransferStatus.STATUS.LOAD_ING)
                            {
                                toBeRemoved.Add(status);
                            }
                        }

                        foreach (var status in toBeRemoved)
                        {
                            m_FtpTransferStatus.Remove(status);
                        }
                    }

                    if (m_FtpTransferStatus.Count() >= 5)
                    {
                        continue;
                    }
                }

                Device Device = m_Devices[i];
                AddLog(string.Format("HTTP ({0}): Sending Upgrade Command", Device.ip));

                FtpTransferStatus transferStatus = new FtpTransferStatus(Device, i, m_FilePath);
                var result = await ICMServer.Net.HttpClient.SendFirmwareUpgradeNotification(Device.ip, Config.Instance.LocalIP, m_FilePath);

                //string uri = string.Format("http://{0}/dev/info.cgi?action=upgrade_fw&url=ftp://{1}/{2}",
                //    Device.ip, Config.Instance.LocalIP, m_FilePath.Replace(@"\", "/"));
                //System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                //client.Timeout = new TimeSpan(0, 0, 1);
                try
                {
                    if (result)
                    {
                        // var response = await client.GetStringAsync(uri);
                        AddLog(string.Format("HTTP ({0}): Send Upgrade success!", Device.ip));
                        SetStatusColumnText(i, "0%", Color.Black);  // TODO: Progress bar
                    }
                    else
                    {
                        transferStatus.Status = FtpTransferStatus.STATUS.LOAD_ERROR;
                        AddLog(string.Format("HTTP ({0}): Send Upgrade fail!", Device.ip));
                        SetStatusColumnText(i, "send upgrade command fail!", Color.Red);
                    }
                }
                catch (Exception) { }

                lock (m_FtpTransferStatus)
                {
                    m_FtpTransferStatus.Add(transferStatus);
                }
                ++i;
            }
            AddLog("Leave Update Thread");
        }