private void RunNextInQueue()
 {
     if (pendingAds.Any())
     {
         if (runningAd != null && runningAd.RunningCreativeSet != null)
         {
             // we had a soft cancel, which means that there are still running creativesets
             runningAd.Cancel();
         }
         runningAd = pendingAds.Dequeue();
         runningAd.RunCompleted += ad_RunCompleted;
         runningAd.RunAsync();
     }
     else
     {
         if (runningAd == null || runningAd.RunningCreativeSet == null)
         {
             // there are no actively running creative sets, we're done!
             Cleanup();
             OnCompleted(true);
         }
         else
         {
             // there are still some creatives running but they are companion ads and can be trumped as soon as another ad comes along
             if (ReleasePlayer != null) ReleasePlayer(this);
         }
     }
 }
 public AdCompletedEventArgs(Ad Ad, bool Success)
 {
     ad      = Ad;
     success = Success;
 }
 public AdCompletedEventArgs(Ad Ad, bool Success)
 {
     ad = Ad;
     success = Success;
 }
 private void vastAd_RunCompleted(Ad vastAd, bool success)
 {
     if (VastAdCompleted != null) VastAdCompleted(this, new AdCompletedEventArgs(vastAd as VastAd, success));
 }
 private void ad_RunCompleted(Ad ad, bool success)
 {
     ad.RunCompleted -= ad_RunCompleted;
     OnRunCompleted(success);
 }
        /// <summary>
        /// Cleans up the AdPod by canceling all running Ads if any exist.
        /// </summary>
        protected virtual void Cleanup()
        {
            // clean up
            pendingAds = null;

            if (runningAd != null)
            {
                runningAd.RunCompleted -= ad_RunCompleted;
                runningAd.Cancel();
                runningAd = null;
            }
        }
 private void ad_RunCompleted(Ad ad, bool success)
 {
     ad.RunCompleted -= ad_RunCompleted;
     OnRunCompleted(success);
 }