Я использую DispatcherTimer
для обработки метода в указанный интервал времени
dispatcherTimer = new DispatcherTimer()
{
Interval = new TimeSpan(0, 0, 0, 1, 0)
};
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
Вот метод dispatcherTimer_Tick
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
try
{
Task.Run(() => MethodWithParameter(message));
}
catch (Exception ex)
{
}
}
Здесь я звоню MQTTPublisher
которая является ссылкой на DLL.
private async static void MethodWithParameter(string message)
{
try
{
await MQTTPublisher.RunAsync(message);
}
catch (Exception Ex)
{
}
}
Я не могу отловить исключения, которые выбрасываются в эту DLL.Как я могу получить исключение для вызывающей стороны?
Определение RunAsync - это в отдельной dll.
public static async Task RunAsync(string message)
{
var mqttClient = factory.CreateMqttClient();
//This creates MqttFactory and send message to all subscribers
try
{
await mqttClient.ConnectAsync(options);
}
catch (Exception exception)
{
Console.WriteLine("### CONNECTING FAILED ###" + Environment.NewLine + exception);
throw exception;
}
}
И
Task<MqttClientConnectResult> ConnectAsync(IMqttClientOptions options)