Click or drag to resize
List Accounts Example

Note: This is preliminary documentation provided only as a preview, and is subject to change. Please contact the author for pricing and licensing information.

This topic demonstrates how a list of accounts can be retrieved.

  1. Import the following namespaces:

    C#
    using ETradeNet.Accounts;
    using ETradeNet.Accounts.Data;
  2. Implement the following method:

    C#
    async Task<IEnumerable<Account>> GetAccountsAsync(IAccountsInitializer init)
    {
        using (var accounts = new AccountsService(init))
        {
            var response = await accounts.GetListAsync();
            return response.Account;
        }
    }
We recommend that you accommodate for cancellation by passing a CancellationToken wherever possible (i.e., in all calls that don't result in a Stream). The example above only omits it for clarity.
See Also