From 2550c1ce7ef7984d9135b72f62b4e8fdbf6b949f Mon Sep 17 00:00:00 2001 From: sdcb Date: Sat, 5 Aug 2023 13:57:07 +0800 Subject: [PATCH] Add constructor failing dispose --- build/00-common.linq | 2 +- src/Sdcb.PaddleOCR/QueuedPaddleOcrAll.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/00-common.linq b/build/00-common.linq index 20d9be9..78b2091 100644 --- a/build/00-common.linq +++ b/build/00-common.linq @@ -25,7 +25,7 @@ static ProjectVersion[] Projects = new[] new ProjectVersion("Sdcb.Mkldnn", "0.19"), // 0.19 new ProjectVersion("Sdcb.Paddle2Onnx", "1.0.0-rc.2"), // 1.0.0-rc.2 new ProjectVersion("Sdcb.PaddleInference", "2.5.0.1"), - new ProjectVersion("Sdcb.PaddleOCR", "2.6.0.6-preview.7"), + new ProjectVersion("Sdcb.PaddleOCR", "2.6.0.6-preview.8"), new ProjectVersion("Sdcb.PaddleOCR.Models.Online", "2.6.0.6-preview.6"), new ProjectVersion("Sdcb.PaddleOCR.Models.LocalV3", "2.6.0.6-preview.6"), new ProjectVersion("Sdcb.PaddleDetection", "2.3.3"), diff --git a/src/Sdcb.PaddleOCR/QueuedPaddleOcrAll.cs b/src/Sdcb.PaddleOCR/QueuedPaddleOcrAll.cs index 5cd7147..80428d4 100644 --- a/src/Sdcb.PaddleOCR/QueuedPaddleOcrAll.cs +++ b/src/Sdcb.PaddleOCR/QueuedPaddleOcrAll.cs @@ -37,9 +37,17 @@ public QueuedPaddleOcrAll(Func factory, int consumerCount = 1, int _workers[i] = Task.Run(ProcessQueue); } + try + { #pragma warning disable CS0618 // Method exposed for compatibility to the outside, now it called in constructor, will change to private in a future version. - WaitFactoryReady(); + WaitFactoryReady(); #pragma warning restore CS0618 // Method exposed for compatibility to the outside, now it called in constructor, will change to private in a future version. + } + catch (AggregateException) + { + Dispose(); + throw; + } } ///