Skip to content

Update Draft Styles from Template -- Long delay on first file #209

@rmcanany

Description

@rmcanany

The delay is occurring after Sub ProcessInternal finishes and its caller Sub Process itself finishes. One way to see it is to place a break point on each of those Subs at the End Sub statement.

The same thing happens with the Create Drawing of Flat Pattern command. Both open a Draft template and they're the only ones that do. I haven't witnessed the delays with any other command. Here's the caller code. (It's the same for every command.)

    Public Overrides Sub Process(
        ByVal SEDoc As SolidEdgeFramework.SolidEdgeDocument,
        ByVal SEApp As SolidEdgeFramework.Application)

        Me.TaskLogger = Me.FileLogger.AddLogger(Me.Description)

        InvokeSTAThread(
            Of SolidEdgeFramework.SolidEdgeDocument,
            SolidEdgeFramework.Application)(
                AddressOf ProcessInternal,
                SEDoc,
                SEApp)
    End Sub

InvokeSTAThread is in HCIsolatedTaskProxy. It looks like this:

    Protected Sub InvokeSTAThread(Of TArg1, TArg2)(ByVal target As Action(Of TArg1, TArg2), ByVal arg1 As TArg1, ByVal arg2 As TArg2)
        If target Is Nothing Then Throw New ArgumentNullException("target")
        Dim exception As Exception = Nothing
        Dim thread = New System.Threading.Thread(
            Sub()
                Try
                    target(arg1, arg2)
                Catch ex As System.Exception
                    exception = ex
                End Try
            End Sub)
        thread.SetApartmentState(System.Threading.ApartmentState.STA)
        thread.Start()
        thread.Join()

        If exception IsNot Nothing Then
            Throw New System.Exception("An unhandled exception has occurred. See inner exception for details.", exception)
        End If
    End Sub

@farfilli @ChrisClems can either of you think of a reason, or a way to test?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions