Example #1
0
 public void OnSearchFlightsCompleted(object sender, SearchCompletedEventArgs eventArgs)
 {
     try
     {
         CheckExistsAndInsertToCache();
         if (eventArgs != null)
         {
             if (eventArgs.Results != null)
             {
                 _flightResultsCacheProvider.UpdateResults(SearchKey, eventArgs.Results);
             }
             else if (eventArgs.Error != null)
             {
                 Logger.LogException(eventArgs.Error, "FlightSearch", "OnSearchFlightsCompleted", Severity.Major);
             }
         }
     }
     finally
     {
         _flightResultsCacheProvider.SetCompleteStatus(SearchKey, IsComplete);
     }
 }
Example #2
0
 private void OnSearchCompleted(SearchCompletedEventArgs e)
 {
     if (SearchFlightsCompleted != null)
     {
         SearchFlightsCompleted(this, e);
     }
 }
Example #3
0
        // This is the method that the underlying, free-threaded
        // asynchronous behavior will invoke.  This will happen on
        // an arbitrary thread.
        private void CompletionMethod(
            List<AirItinerary> airItineraries,
            ISupplier supplier,
            Exception exception,
            bool canceled,
            AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (_userStateToLifetime.SyncRoot)
                {
                    _userStateToLifetime.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Package the results of the operation in a
            // SearchCompletedEventArgs.
            var e =
                new SearchCompletedEventArgs(
                    airItineraries,
                    supplier,
                    exception,
                    canceled,
                    asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible
            // for marshaling the call.
            asyncOp.PostOperationCompleted(_onCompletedDelegate, e);

            // Note that after the call to OperationCompleted,
            // asyncOp is no longer usable, and any attempt to use it
            // will cause an exception to be thrown.
        }