Example #1
0
        private static IEnumerator <Int32> FetchStockQuotesAsyncEnumerator(AsyncEnumerator ae, WebService svc)
        {
            svc.BeginFetchStockQuotes(ae.End(), null);
            yield return(1);

            IStockQuote qt = svc.EndFetchStockQuotes(ae.DequeueAsyncResult());
        }
Example #2
0
        // Sync.

        private static void FetchStockQuotesSync(WebService svc)
        {
            // This blocks. You don't know when the FetchStockQuotes
            // method returns. It may takes from minutes, to hours or
            // it may not return at all.
            IStockQuote qt = svc.FetchStockQuotes();
        }
Example #3
0
        private void GetStockQuotesHelper(Object state)
        {
            // We know that it's really an AsyncResult<IStockQuote> object.
            AsyncResult <IStockQuote> ar = (AsyncResult <IStockQuote>)state;

            try
            {
                // Perform the operation; if sucessful set the result.
                IStockQuote quotes = FetchStockQuotes();
                ar.SetAsCompleted(quotes, false);
            }
            catch (Exception e)
            {
                // If operation fails, set the exception.
                ar.SetAsCompleted(e, false);
            }
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebService"/> class.
 /// </summary>
 /// <param name="quotes">The quotes.</param>
 public WebService(IStockQuote quotes)
 {
     m_quotes = quotes;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebService"/> class.
 /// </summary>
 /// <param name="quotes">The quotes.</param>
 public WebService(IStockQuote quotes)
 {
     m_quotes = quotes;
 }
Example #6
0
 public WebApp(IAuthenticator authenticator, IStockQuote quotes)
 {
     this.authenticator = authenticator;
     this.quotes = quotes;
 }
Example #7
0
 public WebApp(IAuthenticator authenticator, IStockQuote stockQuote)
 {
     _authenticator = authenticator;
       _stockQuote = stockQuote;
 }
Example #8
0
 public WebService(IAuthenticator authenticator, IStockQuote quotes)
 {
     _authenticator = authenticator;
     _quotes        = quotes;
 }
Example #9
0
 public WebService(IAuthenticator authenticator, IStockQuote quotes)
 {
     this.authenticator = authenticator;
     this.quotes        = quotes;
 }
Example #10
0
 public WebApp(IAuthenticator authenticator, IStockQuote stockQuote)
 {
     this.Authenticator = authenticator;
     this.StockQuote    = stockQuote;
 }
Example #11
0
        // Async CTP

        private static async void FetchStockQuotesAsyncCtp(WebService svc)
        {
            IStockQuote qt = await svc.FetchStockQuotesTaskAsync();
        }
Example #12
0
 private static void FetchStockQuotesApmCallback(IAsyncResult ar)
 {
     // This never blocks. Your code returns immediately.
     Func <IStockQuote> @delegate = (Func <IStockQuote>)ar.AsyncState;
     IStockQuote        qt        = @delegate.EndInvoke(ar);
 }
Example #13
0
 private static void FetchStockQuotesApmCallback(IAsyncResult ar)
 {
     // This never blocks. Your code returns immediately.
     WebService  svc = (WebService)ar.AsyncState;
     IStockQuote qt  = svc.EndFetchStockQuotes(ar);
 }
Example #14
0
 public WebService(IAuthenticator authenticator, IStockQuote quotes)
 {
     _authenticator = authenticator;
     _quotes = quotes;
 }
Example #15
0
 public WebApp(IAuthenticator authenticator, IStockQuote stockQuote)
 {
     this.Authenticator = authenticator;
     this.StockQuote = stockQuote;
 }