// constructors // ... // other methods public void PerformExternalOperation() { lock (_sync) { Result result = _resource.Execute(); // do soemthing with the result } }
public void Run() { _running = true; while (_running) { Request request = null; if (_requestQueue.TryDequeue(ref request) && request != null) { _resource.Execute(request); } } }