1. #1
    Ext User
    Join Date
    Dec 2009
    Posts
    2
    Vote Rating
    0
    Raka is on a distinguished road

      0  

    Default Browser freezes when control returns from DirectHandler.ProcessRequest method

    Browser freezes when control returns from DirectHandler.ProcessRequest method


    Hi -- We are making an asynchronous call to a WebService with something like --
    Service.get(Ext.encode(values), callbackMethod);

    in Javascript. We also have a progressbar created in javascript with --
    Ext.MessageBox.show({
    progress: true,
    title: 'Title',
    msg: '...',
    progressText: '...'
    }

    startTime = new Date();
    setTimeout('updateProgressBar(startTime)', 1000);


    We define updateProgressBar as
    updateProgressBar = function(startTime) {
    if (Ext.MessageBox.isVisible())
    {
    ...
    Ext.MessageBox.updateText(...);
    }
    }


    While the server call executes, the progress bar updates correctly. We also have a ProcessRequest method defined as:

    public class DirectHandler : IHttpHandler
    {
    public void ProcessRequest(HttpContext context)
    {
    System.Net.ServicePointManager.Expect100Continue = false;
    DirectProvider p = DirectProviderCache.GetInstance()['Ext.app.REMOTING_API'];
    context.Response.Contenttype = 'text/javascript';
    context.Response.Write(DirectProcessor.Execute(p, context.Request));
    } // A
    }

    I have a breakpoint set at the curly brace marked with "// A". The control comes to it fairly quickly and progress bar is still updating. As soon as I step out of the '// A' line, the progress bar freezes for a while.


    Apparently it is doing something in ExtJs code - running some javascript and so since javascript is single-threaded, the control won't go to the updateProgressBar code and it looks to be frozen. Eventually it returns and goes on merrily.

    I have googled and read many posts but can't find anyone with similar problem. Could someone please help?

    Thanks - Raka

  2. #2
    Ext User
    Join Date
    Dec 2009
    Posts
    2
    Vote Rating
    0
    Raka is on a distinguished road

      0  

    Default


    Ok - I have an update.
    The problem is in ext-all-debug.js -- handleResponse function.
    function handleResponse(response) {
    ...
    ...
    if (options.callback) {
    options.callback.call(options.scope, options, true, response); // <<<<<<<
    }

    If I step into the marked line then I can see the delay happening when it tries to decode the response in doDecode() method --
    doDecode = function(json) { return eval("(" + json + ')');
    }

    So, I want to update the handleResponse method as --


    function handleResponse(response) {
    Ext.MessageBox.updateText('finalizing, please wait...');
    ...
    ...
    if (options.callback) {
    options.callback.call(options.scope, options, true, response); // <<<<<<<
    }

    so that user can see that the messagebox text has updated.
    But if I run this under the debugger, I can see the message getting updated. But if I run it without the debugger then it doesn't show the updated message until the very end - and that is only for a split second.

    Does anyone have an idea about how to update the MessageBox at the beginning of "handleReponse" method?

    Thanks