Corregido problema por el que no mostraba la ultima notificacion.

This commit is contained in:
Miguel 2024-04-26 12:54:24 +02:00
parent 52e59de230
commit 9b03bce9d6
2 changed files with 6 additions and 7 deletions

View File

@ -48,21 +48,19 @@ namespace GTPCorrgir
} }
catch (Exception ex) catch (Exception ex)
{ {
// Manejo de errores (puedes mostrar un mensaje de error si es necesario)
Console.WriteLine("Error durante la corrección de texto: " + ex.Message); Console.WriteLine("Error durante la corrección de texto: " + ex.Message);
} }
finally finally
{ {
// Asegura que el timer se detenga y la notificación se actualice en el hilo de la UI Dispatcher.Invoke(async () => // Nota el 'async' aquí para permitir 'await'
Dispatcher.Invoke(() =>
{ {
CorreccionFinalizada = true; CorreccionFinalizada = true;
DetenerCronometro(); DetenerCronometro();
if (GTP.TextoCorregido != null) if (GTP.TextoCorregido != null)
{ {
System.Windows.Clipboard.SetText(GTP.TextoCorregido); System.Windows.Clipboard.SetText(GTP.TextoCorregido);
ShowCustomNotification("Se puede pegar", $" Correccion en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s" ); ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s");
Thread.Sleep(5000); // Espera 5 segundos await Task.Delay(5000); // Asíncrono espera 5 segundos
} }
else else
{ {
@ -72,6 +70,7 @@ namespace GTPCorrgir
}); });
} }
}); });
} }
private void ShowCustomNotification(string title, string message) private void ShowCustomNotification(string title, string message)

View File

@ -87,8 +87,8 @@ namespace GTPCorrgir
Log.Log("Texto marcado: " + TextoACorregir); Log.Log("Texto marcado: " + TextoACorregir);
//string RespuestaLLM = await CallOpenAiApi(TextoACorregir); string RespuestaLLM = await CallOpenAiApi(TextoACorregir);
string RespuestaLLM = await CallOllamaApi(TextoACorregir); //string RespuestaLLM = await CallOllamaApi(TextoACorregir);
Log.Log("Respuesta: " + RespuestaLLM); Log.Log("Respuesta: " + RespuestaLLM);