When you have a time consuming method in your custom sharepoint code, you can give the user a nice animated
this is done quite easily. The SharePoint namespace provides a class called SPLongOperation use an object of this class to call its Begin() and End() methods. You need to define to the End() method a string that contains the redirect url after the operation is completed.
using (SPLongOperation ctx = new SPLongOperation(this.Page))