|
| 1 | +--- |
| 2 | +title: Timeout Mechanism in Document Processing Libraries |
| 3 | +description: Compiler Warning (level 2) CS0618 in Document Processing Libraries after upgrading. |
| 4 | +type: how-to |
| 5 | +page_title: Timeout Mechanism in Document Processing Libraries |
| 6 | +slug: timeout-mechanism-in-dpl |
| 7 | +tags: timeout, obsolete, import, export, CS0618, warning |
| 8 | +res_type: kb |
| 9 | +--- |
| 10 | + |
| 11 | +## Environment |
| 12 | + |
| 13 | +| Version | Product | Author | |
| 14 | +| --- | --- | ---- | |
| 15 | +| Q4 2024 | Document Processing Libraries |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)| |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | +After upgrading to **Q2 2024** (or a newer version) of Telerik Document Processing Libraries and you have any logic for importing or exporting documents in your application, one of the following warning messages may occur if you try building the project: |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +The [Compiler Warning (level 2) CS0618](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0618?f1url=%3FappId%3Droslyn%26k%3Dk(CS0618)) indicates that an obsolete **Import** or **Export** method is used: |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +## Solution |
| 28 | + |
| 29 | +In Q4 2024 Telerik Document Processing Libraries introduced a new **timeout mechanism** for importing and exporting documents. The Import and Export methods of all FormatProviders have a mandatory **TimeSpan?** timeout parameter after which the operation will be cancelled: |
| 30 | + |
| 31 | +>note This is valid for all Document Processing Libraries. |
| 32 | +
|
| 33 | +#### Import XLSX (Excel Workbook) file |
| 34 | + |
| 35 | + ```csharp |
| 36 | + using (Stream input = new FileStream("input-file.xlsx", FileMode.Open)) |
| 37 | + { |
| 38 | + XlsxFormatProvider formatProvider = new XlsxFormatProvider(); |
| 39 | + TimeSpan timeoutInterval = TimeSpan.FromSeconds(10); |
| 40 | + Workbook workbook = formatProvider.Import(input, timeoutInterval); |
| 41 | + } |
| 42 | + ``` |
| 43 | + |
| 44 | +>note The [TimeSpan](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-timespan) interval is up to the developer and should be considered with the environment specific configurations. |
| 45 | + |
| 46 | +Note that there is a Visual Studio setting that controls whether the [warnings will be treated as errors](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings): |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +Make sure that it is not toggled. Otherwise, the application wouldn't be compiled due to the obsolete API. |
| 51 | + |
| 52 | +## See Also |
| 53 | + |
| 54 | +- [Using PdfFormatProvider in RadPdfProcessing]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider%}) |
| 55 | +- [Using DocxFormatProvider in RadWordsProcessing]({%slug radwordsprocessing-formats-and-conversion-docx-docxformatprovider%}) |
0 commit comments