Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using an AppPage showed up in a ModalDialog and when I click on a button action I try to start a SPLongOperation process, but it only shows the processing panel right before it ends.

here is the code:

protected void CustomBtnClick(object sender, EventArgs e)
{
    try
    {
        SPLongOperation.BeginOperation beginOperation = delegate(SPLongOperation operation)
                                            {
                                                operation.LeadingHTML = "Please wait while the operation is running.";
                                                operation.TrailingHTML = "Running stuff that takes time.";
                                                operation.Begin();

                                                //My Long Operation Code

                                                operation.EndScript("window.frameElement.commitPopup();");
                                            };
        SPLongOperation.Begin(beginOperation);
    }
    catch (ThreadAbortException) {/* Thrown when redirected */}
    catch (Exception ex)
    {
        SPUtility.TransferToErrorPage(ex.ToString());
    }
}

the prime idea is to lock the app page and then give back some feedback messages.

any correction or alternative approach is welcome!

spregards

share|improve this question
    
Did you find a solution to this problem? I have the same behaviour where the panel only shows when processing ends. In my development environment the panel shows, the process takes a long time, and then the user is redirected. On our production environment the process takes a long time, then the panel shows and is immediately redirected, which I think is the problem you were having? Did you solve it? –  robwilliams Jan 10 '13 at 14:30
    
Rob, are both enviromments with the same installed SP version? –  fallout Jan 10 '13 at 14:43
    
Both are Server 2010 installs on Windows Server 2008. I can backup and restore both ways so I assume they are patched to the same version as well? –  robwilliams Jan 10 '13 at 18:37
    
This situation occours, in my scenario, cause the installed versions were different (Standard and Enterprise). But actually I didn't find out what is the specific diff between them that results in that behavior. FYI: works with Standard SP version –  fallout Jan 11 '13 at 9:35
    
Curious, both the environments in question have the same editions installed i.e. SharePoint Foundation 2010, SharePoint Server 2010 Enterprise & Office Web Companions 2010 (as per the SKUs listed by 'get-spfarm | select Products'). The only difference is the dev environment has Project Server 2010 too, though I can't imagine that enables the SPLongOperation. Thanks for the info fallout, if I find anything further interesting I'll update here. –  robwilliams Jan 11 '13 at 13:33

1 Answer 1

up vote 1 down vote accepted

The way I usually use it is something like this:

protected void CustomBtnClick(object sender, EventArgs e) 
{ 
    using (var operation = new SPLongOperation(this.Page))
    {
        try
        {    
            operation.LeadingHTML = "Please wait while the operation is running."; 
            operation.TrailingHTML = "Running stuff that takes time."; 
            operation.Begin(); 

            //My Long Operation Code 

            operation.EndScript("window.frameElement.commitPopup();"); 
        }
        catch (ThreadAbortException) {/* Thrown when redirected */} 
        catch (Exception ex) 
        { 
            SPUtility.TransferToErrorPage(ex.ToString()); 
        } 
    } 
} 
share|improve this answer
    
thanks for the reply Jakob, but even with that approach I not even see the processing panel. I don't really understand what's wrong. –  fallout Mar 28 '12 at 13:43
    
I've just tested this code in a webpart using Thread.Sleep(3000) as my long operation and it works perfectly –  Per Jakobsen Mar 29 '12 at 18:23
    
You are right. Actually also my code is working just fine, I just notice that when I made an deploy to a new environment. I'm still try to find the cause of it not working in the other environment...thanks so much for trying to helping me out with this. –  fallout Mar 30 '12 at 7:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.