Completed
Last Updated: 17 Jun 2025 07:19 by ADMIN
Release 2025.2.520 (2025 Q2)
Flemming
Created on: 04 Mar 2025 08:03
Category: SpreadProcessing
Type: Bug Report
3
SpreadProcessing: ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. (Parameter 'delay') when using timeout with Timespan.MaxValue
This is a sample code to replicate the error which is triggered on export: 
            string inputFileName = "input.xlsx";
            if (!File.Exists(inputFileName))
            {
                throw new FileNotFoundException(String.Format("File {0} was not found!", inputFileName));
            }

            Telerik.Windows.Documents.Spreadsheet.Model.Workbook workbook;
            IWorkbookFormatProvider formatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider();

            using (Stream input = new FileStream(inputFileName, FileMode.Open))
            { 
                workbook = formatProvider.Import(input, TimeSpan.MaxValue);
            }
            string outputFilePath = "output.xlsx";

            using (Stream output = new FileStream(outputFilePath, FileMode.Create))
            {
                formatProvider.Export(workbook, output, TimeSpan.MaxValue);
            }
            Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
3 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 17 Jun 2025 07:19

Hello, Flemming and Piet,

The TimeSpan interval is up to the developer and should be considered with the environment-specific configurations. In case of developing a web application for example, set such a timeout interval value that would be safe enough to protect the application from potential DDoS attacks. If the application is expected to be delivered directly to the end-users, it is possible to use TimeSpan=null as well.

Piet opened a separate public item for improving how the TimeSpan ranges are handled. You can cast your vote for the item, track its progress, subscribe for status changes, and add your comments on the following link:

CancelationTokenSourceFactory.CreateTokenSource(TimeSpan? timeSpan) does not do proper argument checking

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Flemming
Posted on: 12 Jun 2025 09:50

It may come down to .NET design; but FormatProvidor is (I assume) Telerik code, and since you are defining a TimeSpan argument to the method;, IMHO you should also take care of any value passed.

I don't expect an exception on a valid argument not found by the compiler.

Anyway, it is not a showstopper, just nuisance ....

Piet
Posted on: 11 Jun 2025 14:00

this is normal .NET cancellation behavior, the maximum timeout is int.MaxValue or (uint.MaxValue-1) milliseconds (see here), which is many orders of magnitude smaller than TimeSpan.MaxValue.

If you do not want a timeout, which seems to be the intention here, you should pass Timeout.InfiniteTimespan instead of TimeSpan.MaxValue.