How can I cancel a conversion if it hangs? I use the GroupDocs.Conversion.Converter.Convert method to convert a dfx-file to a PDF. However, the process has been hanging for over 20 minutes and I would like to abort it using code. Is there a way to cancel the process after a certain time, for example with a cancellation token? Or is there also an asynchronous method?
Please share following details and weβll investigate this scenario:
- API version that you are evaluating (e.g. 19.10, 20.3)
- Sample code your wrote for the conversion process
- For what document type conversion process hangs
- Sample/problematic documents
Details test scenario:
API version: 20.4.0
Test project type: ASP.NET Web Application (.NET Framework 4.7.2, Visual Basic)
Test code snippet (Visual Basic):
Imports System.Web.Http
Imports GroupDocs.Conversion
Imports GroupDocs.Conversion.Options.Convert
Public Class TestController
βInherits ApiController
β<HttpGet> Public Function GetTestConvertToPdf(sourceFileName As String) As Byte()
ββUsing sourceStream As New IO.FileStream(sourceFileName, IO.FileMode.Open)
βββUsing converter = New Converter(Function() sourceStream)
ββββDim convertOptions = New PdfConvertOptions
ββββUsing outputStream As New IO.MemoryStream
βββββconverter.Convert(Function() outputStream, convertOptions)
βββββReturn outputStream.ToArray
βββ End Using
βββEnd Using
ββEnd Using
βEnd Function
End Class
Document type: dxf to pdf
Sample/problematic documents: I canβt share this documents because it contains personal data.
But the real question is not why the process hangs, but how I can cancel a conversion process.
Iβm looking for a solution like this:
Dim cts = New Threading.CancellationTokenSource
cts.CancelAfter(New TimeSpan(0, 1, 0))
Await converter.ConvertAsync(Function() outputStream, convertOptions, cts.Token)
But there is no async method available.
Thanks for the details. We have logged this scenario as an investigation in our internal issue tracking system with ID CONVERSIONNET-3882. As thereβs any update, youβll be notified.
Is there any news about this?
API doesnβt support any kind of thread management and cancellation at the moment.
I know that this support doesnβt exist at the moment. But is there any support in the future?