I'm trying to use SPLongOperation like in the snippet below. When I run SPDisposeCheck, I get an error. So I have these questions:
- Wouldn't the using statement call Dispose() on SPSite when execution is completed?
How can I give a friendly error message, regardless of the type of exception thrown during the long runnig process?
protected void btn_click(object sender, EventArgs e) { // ..... removed for brevity SPLongOperation longOp = new SPLongOperation(this.Page); longOp.Begin(); try //getting error: Disposable type not disposed: Microsoft.SharePoint.SPSite { using(SPSite oSite = new SPSite(SPContext.Current.Site.Url)) { using(SPWeb oWeb = oSite.OpenWeb(client)) { // do long running process // throw new Exception("Something went wonky!"); } } longOp.End(redirectUrl); } catch (ThreadAbortException) { } catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } }