samples/TodoApp/TodoApp.Data/Services/RemoteTodoService.cs
/// <summary>
/// Initialize the connection to the remote table.
/// </summary>
/// <returns></returns>
Initialize the connection to the remote table.
Initialize the connection to the remote table .
private async Task InitializeAsync()
        {
            if (_initialized)
            {
                return;
            }
            try
            {
                await _asyncLock.WaitAsync();
                if (_initialized)
                {
                    return;
                }
                var options = new DatasyncClientOptions
                {
                    HttpPipeline = new HttpMessageHandler[] { new LoggingHandler() }
                };
                _client = TokenRequestor == null 
                    ? new DatasyncClient(Constants.ServiceUri, options)
                    : new DatasyncClient(Constants.ServiceUri, new GenericAuthenticationProvider(TokenRequestor), options);
                _table = _client.GetRemoteTable<TodoItem>();
                _initialized = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _asyncLock.Release();
            }
        }
private async Task InitializeAsync ( ) { if ( _initialized ) { return ; } try { await _asyncLock . WaitAsync ( ) ; if ( _initialized ) { return ; } var options = new DatasyncClientOptions { HttpPipeline = new HttpMessageHandler [ ] { new LoggingHandler ( ) } } ; _client = TokenRequestor == null ? new DatasyncClient ( Constants . ServiceUri , options ) : new DatasyncClient ( Constants . ServiceUri , new GenericAuthenticationProvider ( TokenRequestor ) , options ) ; _table = _client . GetRemoteTable < TodoItem > ( ) ; _initialized = true ; } catch ( Exception ) { throw ; } finally { _asyncLock . Release ( ) ; } }
Initialize the connection to the remote table.
Initialize the connection to the remote table .
// Short circuit, in case we are already initialized. // Wait to get the async initialization lock // This will also execute the async lock. // Initialize the client. // Set _initialied to true to prevent duplication of locking. // Re-throw the exception.
None