Convert method hangs / how to abort the method in .NET

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?

1 Like

@mario.ableidinger,

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.

1 Like

@mario.ableidinger,

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?

@mario.ableidinger

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?

@mario.ableidinger

We’ll further investigate it and let you know about the outcomes.