Solid Edge Framework Type Library
DoIdle Method
Solid Edge Framework Type Library > Application Object : DoIdle Method
Description
Gives idle time to the application. Call the DoIdle() method to provide the application with the opportunity to perform background tasks that may not be up-to-date because of intense processing.
Syntax
Visual Basic
Public Sub DoIdle() 
Remarks

In automation situations where a client is keeping Solid Edge extremely busy, Solid Edge will not have an opportunity to perform background tasks. Depending on the automation scenario, this could mean that certain objects may not be in an expected state.

One of the most important tasks that DoIdle() performs is to ensure that a SolidEdgeDocument gets fully released after SolidEdgeDocument.Close is called. This is significant because even though SolidEdgeDocument.Close is called, the calling client is still holding a reference to the COM object via IUnknown.AddRef(). It is recommended that DoIdle() be called after any document is closed if the client that closed the document is going to do more processing before returning control to Solid Edge.

The following list are examples of background tasks that Solid Edge may perform during DoIdle() processing.

Example
Option Infer On

Imports System
Imports System.Runtime.InteropServices

Namespace Examples
    Friend Class Program
        <STAThread>
        Shared Sub Main(ByVal args() As String)
            Dim application As SolidEdgeFramework.Application = Nothing

            Try
                ' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register()

                ' Attempt to connect to a running instance of Solid Edge.
                application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)

                ' Get the documents collection.
                Dim documents = application.Documents

                ' Close all open documents.
                Do While documents.Count > 0
                    ' Get the document at index 1.
                    Dim document = CType(documents.Item(1), SolidEdgeFramework.SolidEdgeDocument)

                    ' Close the document.
                    document.Close(SaveChanges:= False)

                    ' Solid Edge can't fully release the document since we still have a reference to it.
                    Marshal.FinalReleaseComObject(document)
                    document = Nothing

                    ' Give Solid Edge an opportunity to complete cleanup.
                    application.DoIdle()
                Loop
            Catch ex As System.Exception
                Console.WriteLine(ex)
            Finally
                OleMessageFilter.Unregister()
            End Try
        End Sub
    End Class
End Namespace
using System;
using System.Runtime.InteropServices;

namespace Examples
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;

            try
            {
                // See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register();

                // Attempt to connect to a running instance of Solid Edge.
                application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

                // Get the documents collection.
                var documents = application.Documents;

                // Close all open documents.
                while (documents.Count > 0)
                {
                    // Get the document at index 1.
                    var document = (SolidEdgeFramework.SolidEdgeDocument)documents.Item(1);

                    // Close the document.
                    document.Close(SaveChanges: false);

                    // Solid Edge can't fully release the document since we still have a reference to it.
                    Marshal.FinalReleaseComObject(document);
                    document = null;

                    // Give Solid Edge an opportunity to complete cleanup.
                    application.DoIdle();
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                OleMessageFilter.Unregister();
            }
        }
    }
}
See Also

Application Object  | Application Members