From 9b03bce9d6ae6c5b902efe46221433f8ad16cb44 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 26 Apr 2024 12:54:24 +0200 Subject: [PATCH] Corregido problema por el que no mostraba la ultima notificacion. --- App.xaml.cs | 9 ++++----- gtpask.cs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 3839a81..84634a3 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -48,21 +48,19 @@ namespace GTPCorrgir } 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); } finally { - // Asegura que el timer se detenga y la notificación se actualice en el hilo de la UI - Dispatcher.Invoke(() => + Dispatcher.Invoke(async () => // Nota el 'async' aquí para permitir 'await' { CorreccionFinalizada = true; DetenerCronometro(); if (GTP.TextoCorregido != null) { System.Windows.Clipboard.SetText(GTP.TextoCorregido); - ShowCustomNotification("Se puede pegar", $" Correccion en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s" ); - Thread.Sleep(5000); // Espera 5 segundos + ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s"); + await Task.Delay(5000); // Asíncrono espera 5 segundos } else { @@ -72,6 +70,7 @@ namespace GTPCorrgir }); } }); + } private void ShowCustomNotification(string title, string message) diff --git a/gtpask.cs b/gtpask.cs index 8fbf834..09a69c0 100644 --- a/gtpask.cs +++ b/gtpask.cs @@ -87,8 +87,8 @@ namespace GTPCorrgir Log.Log("Texto marcado: " + TextoACorregir); - //string RespuestaLLM = await CallOpenAiApi(TextoACorregir); - string RespuestaLLM = await CallOllamaApi(TextoACorregir); + string RespuestaLLM = await CallOpenAiApi(TextoACorregir); + //string RespuestaLLM = await CallOllamaApi(TextoACorregir); Log.Log("Respuesta: " + RespuestaLLM);