• CAMAPI
  • API Documentation
Show / Hide Table of Contents
  • Supported programming languages
    • C#
    • Delphi
    • C++
  • Tutorial lessons
    • Lesson 1 - general introduction to the extension ideology using the example of a C# project
    • Lesson 2 - connecting the SDK to a Delphi project using the build system
    • Lesson 3 - connecting the SDK to a C++ project using the build system
    • Lesson 4 - demonstration of methods for unloading an extension during main application is running
    • Lesson 5 - Creating a custom operation
    • Lesson 6 - Creating a C# application to interact with geometry in main application
    • Lesson 7 - Creating a C# application to connect to main application for managing it
    • Lesson 8 - Creating a C# extension to integrate with a PLM system
  • System extensions
    • Extension.Util.Common.Dll
    • Extension.Util.Common.Exe
  • Debugging of extensions
    • Debugging a .NET extension using Visual Studio Code
    • Debugging a Delphi extension using RAD Studio
    • Debugging a C++ extension using Visual Studio
  • Entry points
    • Utilitiy in main form
    • Executor for utility in main form
    • New item to the operation's context menu
  • Machining Tools Import
    • Preparing the environment
    • Working with the tool library
    • Working with cutting tools
      • Milling Tools
      • Turning Tools
      • Custom Axial Shaped Tools
    • Working with the tool holder
  • API Documentation
  • External applications
    • Connecting in a C# application
    • Connecting in a Delphi application
    • Connecting in a C++ application
  • Using ComWrapper

Using ComWrapper

The ENCY core is written in a programming language where memory is released manually — as opposed to languages like C#, which rely on a Garbage Collector that frees memory automatically.

Therefore, when extensions written in .NET interact with the ENCY core, it is necessary to have a mechanism for explicitly releasing COM objects on demand. For this reason, the ComWrapper class was introduced to encapsulate all memory management logic for COM objects.

Problems solved by using the ComWrapper:

  1. Accessing a COM object from multiple threads;
  2. Proper memory cleanup after use, ensuring that the ENCY core can continue functioning correctly.

Examples:

Get another COM-object:

using var ncMakerCom = activeProjectCom.InvokeAndWrap(project => project.NCMaker);

Execute method of COM-object:

applicationCom.Invoke(application =>
{
    application.MainWorkMode = TMainWorkMode.mwmModel;
});

Transfering ownership:

var curveCom2 = curveCom1.TransferOwnership();

Conclusion

Using ComWrapper is mandatory, if your extension is written on .NET.

In this article
Back to top Generated by DocFX