none
IExtractImage.Extract on BackgroundWorker UI lookup RRS feed

  • Question

  • Hi

    I'm using IExtractImage inside a BackgroundWorker.Dowork event to get file thumbnails (using vb.net) but when extracting thumbnails for video files the whole application frezees during the call to IExtractImage.Extract

    the code i'm using is:

            Dim hBmp As IntPtr
            Dim extractImage As IExtractImage = Nothing
            Dim iunk As ShellDll.IUnknown = Nothing
            Dim mPidl() As IntPtr = {IntPtr.Zero}
            Dim imageSize As New SIZE
            Dim folder As IShellFolder = CShItem.GetParentOf(Me.PIDL, mPidl(0))

            Try
                Dim prgf As Integer = 0
                'Dim iidExtractImage As Guid = New Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")
                Dim hr As Integer = folder.GetUIObjectOf(IntPtr.Zero, 1, mPidl, IID_ExtractImage, prgf, iunk)

                If Not hr = 0 Then
                    Marshal.ThrowExceptionForHR(hr)
                End If

                extractImage = CType(iunk, IExtractImage)

                If (extractImage IsNot Nothing) Then
                    Dim location As New StringBuilder(260, 260)
                    Dim priority As Integer = 0
                    Dim requestedColorDepth As Integer = 32
                    Dim uFlags As Integer = IEIFLAG.IEIFLAG_ORIGSIZE + IEIFLAG.IEIFLAG_QUALITY

                    imageSize.cx = size
                    imageSize.cy = size

                    extractImage.GetLocation(location, location.Capacity, priority, imageSize, requestedColorDepth, uFlags)
                    extractImage.Extract(hBmp)

                    If (hBmp <> IntPtr.Zero) Then
                        Return hBmp
                    Else
                        Return Nothing
                    End If
                Else
                    Return Nothing
                End If

            Catch ex As Exception
                Return Nothing
            Finally
                If (iunk IsNot Nothing) Then
                    Marshal.ReleaseComObject(iunk)
                    iunk = Nothing
                End If
                If (folder IsNot Nothing) Then
                    Marshal.ReleaseComObject(folder)
                    folder = Nothing
                End If
                If (extractImage IsNot Nothing) Then
                    Marshal.ReleaseComObject(extractImage)
                    extractImage = Nothing
                End If
                mPidl(0) = IntPtr.Zero
            End Try

     

    Monday, January 3, 2011 7:28 PM

Answers

All replies

  • I suggest you to extract the image of the video in another process. Many video codecs are prone to crash/freeze.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Monday, January 3, 2011 9:50 PM
  • The problem is that i already doing this in another process (using a BackgroundWorker class)
    Tuesday, January 4, 2011 8:17 AM
  •  

    another process? another thread?

     

    BackgroundWorker executes work in a non-UI thread, so if the thread is blocked by IExtractImage.Extract method, the UI thread will not hang.

     

    However, you may following Tess' blog to detect this issue, hope it could be helpful to you.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 5, 2011 8:32 AM
  • IExtractImage.Extract is called in another thread (a BackgroundWorker doWork event) and during it's execution both the backgroundworker and the main ui thread hang
    Wednesday, January 5, 2011 9:10 AM
  • Could you following Tess' blog to do some investigations on this issue?
    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by eryang Monday, January 17, 2011 7:01 AM
    Friday, January 7, 2011 4:47 AM
  • no, i had not enough time to do a sample project and debug it, will try to test it when i had a bunch of free time
    Monday, January 17, 2011 7:51 AM