public IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object state)
    {
        wbsIISAsyncResult = new WBSAsyncResult(cb, state);

        if (bAsyncGetHotelAvailInfo || bAsyncGetHotelAvailCalendarInfo)
        {
            this.BeginResumeAsyncDataCapture();
        }

        else
        {
            while (!ThreadPool.QueueUserWorkItem(new WaitCallback(TerminateAsyncOperation), wbsIISAsyncResult))
                Thread.Sleep(100);
        }

        return wbsIISAsyncResult;
    }
    public IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object state)
    {
        wbsIISAsyncResult = new WBSAsyncResult(cb, state);

        if (bAsyncGetHotelSearchAreaList || bAsyncGetHotelSearchPropertyList || bAsyncGetLoginProfile || bAsyncGetLinkedProfile)
        {
            this.BeginResumeAsyncDataCapture();
        }

        else
        {
            while (!ThreadPool.QueueUserWorkItem(new WaitCallback(TerminateAsyncOperation), wbsIISAsyncResult))
                Thread.Sleep(100);
        }

        return wbsIISAsyncResult;
    }
    public IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object state)
    {
        this.EventLog.Write(Page.Session.SessionID + ", enter BeginAsyncOperation, " + DateTime.Now.ToString("MM dd yyyy HH:mm:ss.ffffff"));

        wbsIISAsyncResult = new WBSAsyncResult(cb, state);

        if (bAsyncGetHotelAvailInfo)
        {
            this.BeginResumeAsyncDataCapture();
        }

        else
        {
            while (!ThreadPool.QueueUserWorkItem(new WaitCallback(TerminateAsyncOperation), wbsIISAsyncResult))
                Thread.Sleep(100);
        }

        this.EventLog.Write(Page.Session.SessionID + ", exit BeginAsyncOperation, " + DateTime.Now.ToString("MM dd yyyy HH:mm:ss.ffffff"));

        return wbsIISAsyncResult;
    }
    protected virtual void Page_Init(object sender, EventArgs e)
    {
        dtPageStartTime = DateTime.Now;

        if (Context.Session != null)
        {
            bool bIsNewSessionOverride = false;

            if (Context.Items["IsNewSessionOverride"] != null)
                bIsNewSessionOverride = (bool)Context.Items["IsNewSessionOverride"];

            if (Session.IsNewSession && !bIsNewSessionOverride)
            {
                Response.Redirect("~/Default.aspx");
                return;
            }

        }

        bIsProduction = XnGR_WBS_Page.IsProductionMode();

        if (ConfigurationManager.AppSettings["WBSBookingMode"] == "Production")
            bIsBookThrough = true;
        else
            bIsBookThrough = false;

        if (ConfigurationManager.AppSettings["GuestDetailsTestPrefill"] == "1")
            bIsGuestDetailsTestPrefill = true;
        else
            bIsGuestDetailsTestPrefill = false;

        bIsParentPreRender = false;
        bIsDeepLinkNav = false;

        objEventLog = (FileLog)Application["EventLog"];
        objExceptionEventLog = (ExceptionLog)Application["ExceptionEventLog"];

        wbsAPIRouter = WBSAPIRouter.GetWbsApiRouter(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSAPIRouter.RequestExpirationSeconds"], (int)Application["WBSAPIRouter.WindowUnitSeconds"], (int)Application["WBSAPIRouter.WindowUnits"]);
        wbsAPIRouterData = null;
        wbsIISAsyncResult = null;

        wbsAPI = new WBSAPIRouterHelper(Session, Page, objEventLog, objExceptionEventLog, bIsProduction);
        wbsPG = new WBSPGHelper(Session, Page, objEventLog, objExceptionEventLog, bIsProduction);
        wbsUI = new WBSUIHelper(Session, Page);

        wbsPerfCounters = WBSPerfCounters.GetWbsPerfCounters(Context.Cache, objEventLog, objExceptionEventLog, (string)Application["WBSPerfCounters.PerformanceMonitorGroupName"]);
        wbsServiceTimesUpdater = WBSServiceTimesUpdater.GetWbsServiceTimesUpdater(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSAPIRouter.RequestExpirationSeconds"], (int)Application["WBSAPIRouter.WindowUnitSeconds"], (int)Application["WBSAPIRouter.WindowUnits"], (string)Application["WBSPerfCounters.PerformanceMonitorGroupName"]); // retrieved only as a "keep-alive" mechanism

        wbsMonitor = WBSMonitor.GetWbsMonitor(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSMonitor.ExpirationSeconds"]); // Used for pending prepay bookings logging

        this.InitPageErrors();

        if (!IsPostBack)
        {
            if (Request.QueryString.Get("CrossPageErrors") == "1")
                this.RestoreCrossPageErrors();

            if (Request.QueryString.Get("DeepLinkNav") == "1") // used wtih Response.Redirect
                bIsDeepLinkNav = true;

            if ((string)Context.Items["DeepLinkNav"] == "1") // used with Server.Transfer
                bIsDeepLinkNav = true;
        }

        return;
    }