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: 2023.0.3
Syntax
[SerializableAttribute]
public sealed class Events : MarshalByRefObject

The Events type exposes the following members.

Constructors
  NameDescription
Public methodEvents
Constructs a new instance of Events.
Top
Methods
  NameDescription
Public methodInitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public methodRegister
Registers the instance to listen to the specified events.
Public methodUnRegister
Unregisters the instance from listening to events.
Top
Events
  NameDescription
Public eventDrawingChanged
The DrawingChanged event is raised when the drawing has been changed and the database is committed.
Public eventDrawingDeleted
The DrawingDeleted event is raised when a drawing has been deleted.
Public eventDrawingInserted
The DrawingInserted event is raised when a drawing has been inserted.
Public eventDrawingReadyForIssuingChange
The DrawingReadyForIssuingChange event is raised just after a drawing is marked or unmarked ready for issuing.
Public eventDrawingStatusChanged
The DrawingStatusChanged event is raised when the drawing status has changed.
Public eventDrawingUpdated
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
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next