public static async Task ShowAsync(this IAdvertisement self)
        {
            var promoter         = self.Promoter;
            var outputException  = default(Exception);
            var outputShowResult = default(ShowResult?);

            promoter.ExceptionDetected += OnExceptionDetected;
            self.Show(
                () => outputShowResult = ShowResult.Complete,
                () => outputShowResult = ShowResult.Skip,
                () => outputShowResult = ShowResult.Failure);

            while (!outputShowResult.HasValue)
            {
                await Task.Delay(MillisecondsDelay);
            }

            promoter.ExceptionDetected -= OnExceptionDetected;

            switch (outputShowResult.Value)
            {
            case ShowResult.Complete:
                break;

            case ShowResult.Skip:
                throw new SkipException();

            case ShowResult.Failure:
                throw outputException ?? new InvalidOperationException();
            }

            void OnExceptionDetected(Exception exception)
            {
                outputException = exception;
            }
        }
예제 #2
0
 public void ShowAd(AdType adType)
 {
     advertisement.Show(adType);
 }