#pragma warning disable CS1591
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Common.Events
{
// TODO: @bond Remove
///
/// Class EventHelper
///
public static class EventHelper
{
///
/// Fires the event.
///
/// The handler.
/// The sender.
/// The instance containing the event data.
/// The logger.
public static void QueueEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger)
{
if (handler != null)
{
Task.Run(() =>
{
try
{
handler(sender, args);
}
catch (Exception ex)
{
logger.LogError(ex, "Error in event handler");
}
});
}
}
///
/// Queues the event.
///
///
/// The handler.
/// The sender.
/// The args.
/// The logger.
public static void QueueEventIfNotNull(EventHandler handler, object sender, T args, ILogger logger)
{
if (handler != null)
{
Task.Run(() =>
{
try
{
handler(sender, args);
}
catch (Exception ex)
{
logger.LogError(ex, "Error in event handler");
}
});
}
}
}
}