private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { _grabber?.Dispose(); _visionClient?.Dispose(); } disposedValue = true; } }