public void FindActiveWebService() { lock (FindWebServiceSync) { if (!IsFindingActiveWebService) { IsFindingActiveWebService = true; try { // Lots of crappy code and nested code in here with loops and such. // Planning to refactor all this junk. } finally { IsFindingActiveWebService = false; } } } }Wondering if it would be just as safe to do this and remove the extra if structure.
public void FindActiveWebService() { // Moved outside the lock if (IsFindingActiveWebService) return; lock (FindWebServiceSync) { IsFindingActiveWebService = true; try { // Lots of crappy code and nested code in here with loops and such. // Planning to refactor all this junk. } finally { IsFindingActiveWebService = false; } } }Thanks for any thoughts.