public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive)
        {
            if (pubSubEvent == null)
            {
                throw new ArgumentNullException(nameof(pubSubEvent));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

#if !Android && !iOS && !UWP && !Mac
            if (pubSubEvent.SynchronizationContext == null && threadOption == ThreadOption.UIThread)
            {
                threadOption = ThreadOption.PublisherThread;
            }
#endif

            return(pubSubEvent.Subscribe(async(payload) =>
            {
                try
                {
                    await action(payload);
                }
                catch (Exception exp)
                {
                    BitExceptionHandlerBase.Current?.OnExceptionReceived(exp);
                }
            }, threadOption: threadOption, keepSubscriberReferenceAlive: keepSubscriberReferenceAlive));
        }
Ejemplo n.º 2
0
        public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate <TPayload> filter)
        {
            if (pubSubEvent == null)
            {
                throw new ArgumentNullException(nameof(pubSubEvent));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            return(pubSubEvent.Subscribe(async(payload) =>
            {
                try
                {
                    await action(payload);
                }
                catch (Exception exp)
                {
                    BitExceptionHandlerBase.Current?.OnExceptionReceived(exp);
                }
            }, threadOption: threadOption, keepSubscriberReferenceAlive: keepSubscriberReferenceAlive, filter: filter));
        }
Ejemplo n.º 3
0
 public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action)
 {
     return(pubSubEvent.Subscribe(async(payload) =>
     {
         try
         {
             await action(payload);
         }
         catch (Exception exp)
         {
             BitExceptionHandler.Current.OnExceptionReceived(exp);
         }
     }));
 }
Ejemplo n.º 4
0
 public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate <TPayload> filter)
 {
     return(pubSubEvent.Subscribe(async(payload) =>
     {
         try
         {
             await action(payload);
         }
         catch (Exception exp)
         {
             BitExceptionHandler.Current.OnExceptionReceived(exp);
         }
     }, threadOption: threadOption, keepSubscriberReferenceAlive: keepSubscriberReferenceAlive, filter: filter));
 }
 public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action, bool keepSubscriberReferenceAlive)
 {
     return(pubSubEvent.Subscribe(async(payload) =>
     {
         try
         {
             await action(payload).ConfigureAwait(false);
         }
         catch (Exception exp)
         {
             BitExceptionHandler.Current.OnExceptionReceived(exp);
         }
     }, keepSubscriberReferenceAlive: keepSubscriberReferenceAlive));
 }
 public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action, ThreadOption threadOption)
 {
     return(pubSubEvent.Subscribe(async(payload) =>
     {
         try
         {
             await action(payload).ConfigureAwait(false);
         }
         catch (Exception exp)
         {
             BitExceptionHandler.Current.OnExceptionReceived(exp);
         }
     }, threadOption: threadOption));
 }
        public static SubscriptionToken SubscribeAsync <TPayload>(this PubSubEvent <TPayload> pubSubEvent, Func <TPayload, Task> action)
        {
            if (pubSubEvent == null)
            {
                throw new ArgumentNullException(nameof(pubSubEvent));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(pubSubEvent.Subscribe(async(payload) =>
            {
                try
                {
                    await action(payload);
                }
                catch (Exception exp)
                {
                    BitExceptionHandlerBase.Current?.OnExceptionReceived(exp);
                }
            }));
        }
Ejemplo n.º 8
0
 public static SubscriptionToken Subscribe <TPayload>([NotNull] this PubSubEvent <TPayload> handler, Action <TPayload> action, Predicate <TPayload> filter) =>
 handler.Subscribe(action, default, default, filter);