I am getting data from sharepoint online using WCF that is hosted in IIS. I decided to handle all my errors using this example. In my code I am using ClientContext class that needs to be disposed in a right way
ClientContext _context = new ClientContext(_url);
var list = _context.Web.Lists.GetByTitle(ListName);
ListItem item = list.GetItemById(id);
_context.Load(item, i => i[Description], i => i[Picture], i => i[Title], i => i.Id);
_context.ExecuteQuery();
_context.Dispose();
But if I get exception in _context.ExecuteQuery(); I go to HandleError method
public bool HandleError(Exception error)
{
return true;
}
The question is: How to Dispose client context in this situation?