|
|
@ -132,7 +132,19 @@ public abstract partial class InferenceGenerationViewModelBase |
|
|
|
|
|
|
|
|
|
|
|
// Register progress handler |
|
|
|
// Register progress handler |
|
|
|
promptTask.ProgressUpdate += OnProgressUpdateReceived; |
|
|
|
promptTask.ProgressUpdate += OnProgressUpdateReceived; |
|
|
|
promptTask.RunningNodeChanged += OnRunningNodeChanged; |
|
|
|
|
|
|
|
|
|
|
|
// Delay attaching running node change handler to not show indeterminate progress |
|
|
|
|
|
|
|
// if progress updates are received before the prompt starts |
|
|
|
|
|
|
|
Task.Run( |
|
|
|
|
|
|
|
async () => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
await Task.Delay(200, cancellationToken); |
|
|
|
|
|
|
|
// ReSharper disable once AccessToDisposedClosure |
|
|
|
|
|
|
|
promptTask.RunningNodeChanged += OnRunningNodeChanged; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
cancellationToken |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.SafeFireAndForget(); |
|
|
|
|
|
|
|
|
|
|
|
// Wait for prompt to finish |
|
|
|
// Wait for prompt to finish |
|
|
|
await promptTask.Task.WaitAsync(cancellationToken); |
|
|
|
await promptTask.Task.WaitAsync(cancellationToken); |
|
|
@ -166,15 +178,13 @@ public abstract partial class InferenceGenerationViewModelBase |
|
|
|
client.PreviewImageReceived -= OnPreviewImageReceived; |
|
|
|
client.PreviewImageReceived -= OnPreviewImageReceived; |
|
|
|
|
|
|
|
|
|
|
|
// Clear progress |
|
|
|
// Clear progress |
|
|
|
OutputProgress.Value = 0; |
|
|
|
OutputProgress.ClearProgress(); |
|
|
|
OutputProgress.Text = ""; |
|
|
|
|
|
|
|
ImageGalleryCardViewModel.PreviewImage?.Dispose(); |
|
|
|
ImageGalleryCardViewModel.PreviewImage?.Dispose(); |
|
|
|
ImageGalleryCardViewModel.PreviewImage = null; |
|
|
|
ImageGalleryCardViewModel.PreviewImage = null; |
|
|
|
ImageGalleryCardViewModel.IsPreviewOverlayEnabled = false; |
|
|
|
ImageGalleryCardViewModel.IsPreviewOverlayEnabled = false; |
|
|
|
|
|
|
|
|
|
|
|
// Cleanup tasks |
|
|
|
// Cleanup tasks |
|
|
|
promptTask?.Dispose(); |
|
|
|
promptTask?.Dispose(); |
|
|
|
await promptInterrupt.DisposeAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|