Exemplo n.º 1
0
        public static void InvokeAsync <T1, T2, T3>(this AsyncEvent <Func <T1, T2, T3, Task> > eventHandler, T1 arg1, T2 arg2, T3 arg3)
        {
            var subscribers = eventHandler.Subscriptions;

            foreach (var subscription in subscribers)
            {
                _ = Task.Run(async() =>
                {
                    try
                    {
                        await subscription.Invoke(arg1, arg2, arg3).ConfigureAwait(false);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Something went wrong while executing subscription {subscription.Target}/{subscription.Method.Name} of {eventHandler.GetName()}.");
                        Console.WriteLine(ex);
                    }
                });
            }
        }