/// <inheritdoc cref="ISapPooledConnection"/> public TOutput InvokeFunction <TOutput>(string name, CancellationToken cancellationToken = default) { try { _connection = _connection ?? _pool.GetConnection(cancellationToken); using (ISapFunction function = _connection.CreateFunction(name)) return(function.Invoke <TOutput>()); } catch (SapCommunicationFailedException) { // Let the pool collect the dead connection _pool.ForgetConnection(_connection); // Retry invocation with new connection from the pool _connection = _pool.GetConnection(cancellationToken); using (ISapFunction function = _connection.CreateFunction(name)) return(function.Invoke <TOutput>()); } }
/// <inheritdoc cref="ISapPooledConnection"/> public void InvokeFunction(string name, object input, CancellationToken cancellationToken = default) { try { _connection = _connection ?? _pool.GetConnection(cancellationToken); using (ISapFunction function = _connection.CreateFunction(name)) function.Invoke(input); } catch (SapCommunicationFailedException) { // Let the pool collect the dead connection _pool.ForgetConnection(_connection); // Retry invocation with new connection from the pool _connection = _pool.GetConnection(cancellationToken); using (ISapFunction function = _connection.CreateFunction(name)) function.Invoke(input); } }