Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

Events Class

The Events class allows the user to register event listeners for drawing events.
Inheritance Hierarchy

Namespace:  Tekla.Structures.Drawing
Assembly:  Tekla.Structures.Drawing (in Tekla.Structures.Drawing.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public sealed class Events : MarshalByRefObject

The Events type exposes the following members.

Constructors
  Name Description
Public method Events
Constructs a new instance of Events.
Top
Methods
  Name Description
Public method InitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public method Register
Registers the instance to listen to the specified events.
Public method UnRegister
Unregisters the instance from listening to events.
Top
Events
  Name Description
Public event DrawingChanged
The DrawingChanged event is raised when the drawing has been changed and the database is committed.
Public event DrawingDeleted
The DrawingDeleted event is raised when a drawing has been deleted.
Public event DrawingInserted
The DrawingInserted event is raised when a drawing has been inserted.
Public event DrawingStatusChanged
The DrawingStatusChanged event is raised when the drawing status has changed.
Public event DrawingUpdated
The DrawingUpdated event is raised when the drawing has been inserted, deleted or modified, and the database is committed.
Top
Remarks
Asynchronous event handling

Registered event handlers are called asynchronously so that many handlers may be running simultaneously. Event handlers are not guaranteed to be run in the same thread where they were registered. The asynchronous nature of the events requires the use of synchronization constructs on objects and data structures that are not defined to be thread safe.

  • Microsoft's documentation about the lock statement: http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
  • Microsoft's documentation about delegates: http://msdn.microsoft.com/en-us/library/900fyy8e.aspx
  • Microsoft's documentation about managed threading: http://msdn.microsoft.com/en-us/library/1c9txz50.aspx
Examples
The following example shows how to make sure that only one selection event handler is running at a time.
using Tekla.Structures.Drawing;

   public class Example
   {
       private Events _events = new Events();
       private object _statusChangedEventHandlerLock = new object();

       public void RegisterEventHandler()
       {
           _events.DrawingStatusChanged += Events_DrawingStatusChangedEvent;
           _events.Register();
       }

       public void UnRegisterEventHandler()
       {
           _events.UnRegister();
       }

       void Events_DrawingStatusChangedEvent()
       {
           /* Make sure that the inner code block is running synchronously */
           lock(_statusChangedEventHandlerLock)
           {
               System.Console.WriteLine("Selection changed event received.");
           }
       }
   }
See Also