private void CancelCtx()
 {
     if (m_httpQuery != null)
     {
         m_httpQuery.Cancel();
         m_httpQuery = null;
     }
 }
        private void ConfigKPPEmailVerif_WizardNext(object sender, WizardPageEventArgs e)
        {
            try
            {
                this.Enabled = false;
                e.Cancel = true;

                String kpsAddress = ((ConfigKPPWizard)this.GetWizard()).getSignInKpsAddess();
                String email = ((ConfigKPPWizard)this.GetWizard()).getSignInUserName();

                email = System.Web.HttpUtility.UrlEncode(email);
                String ws_url = "https://" + kpsAddress + "/freemium/registration/" + email + "/verify";

                m_httpQuery = new HttpQuery(new Uri(ws_url));
                m_httpQuery.UseCache = false;
                m_httpQuery.OnHttpQueryEvent += new EventHandler<HttpQueryEventArgs>(HandleHttpQueryResult);
                m_httpQuery.StartQuery();
            }
            catch (Exception ee)
            {
                CancelCtx();
                Base.HandleException(ee);
            }
        }
        private void ConfigKPPCredentials_WizardNext(object sender, WizardPageEventArgs e)
        {
            try
            {
                e.Cancel = true;
                // Hardcode freemium address for now
                this.creds.KpsAddress = "tbsos01.teambox.co";

                WmWinRegistry reg = WmWinRegistry.Spawn();
                if (!(string.IsNullOrEmpty(reg.FreemiumKpsAddr)))
                    this.creds.KpsAddress = reg.FreemiumKpsAddr;

                // Must be disabled after changing the creds.KpsAddress property
                this.Enabled = false;

                string email = this.creds.UserName;
                string pwd = this.creds.Password;
                string ws_url = "https://" + this.creds.KpsAddress + "/freemium/registration";

                string post_params = "";

                email = System.Web.HttpUtility.UrlEncode(email);
                pwd = System.Web.HttpUtility.UrlEncode(pwd);
                post_params = "email=" + email + "&pwd=" + pwd;

                m_httpQuery = new HttpQuery(new Uri(ws_url + "?" + post_params));
                m_httpQuery.UseCache = false;
                m_httpQuery.OnHttpQueryEvent += new EventHandler<HttpQueryEventArgs>(HandleHttpQueryResult);
                m_httpQuery.StartQuery();
            }

            catch (Exception ee)
            {
                // Make sure to release the query if required.
                CancelCtx();
                Base.HandleException(ee);
            }
        }