/// <summary> /// Frees resources for the node configuration. /// </summary> public static void Deinit() { OpcSessions.Clear(); _nodePublishingConfiguration = null; OpcSessionsListSemaphore.Dispose(); OpcSessionsListSemaphore = null; PublisherNodeConfigurationSemaphore.Dispose(); PublisherNodeConfigurationSemaphore = null; PublisherNodeConfigurationFileSemaphore.Dispose(); PublisherNodeConfigurationFileSemaphore = null; }
/// <summary> /// Implement IDisposable. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing) { OpcSessionsListSemaphore.Wait(); foreach (var opcSession in OpcSessions) { opcSession.Dispose(); } OpcSessions?.Clear(); OpcSessionsListSemaphore?.Dispose(); OpcSessionsListSemaphore = null; PublisherNodeConfigurationSemaphore?.Dispose(); PublisherNodeConfigurationSemaphore = null; PublisherNodeConfigurationFileSemaphore?.Dispose(); PublisherNodeConfigurationFileSemaphore = null; _nodePublishingConfiguration?.Clear(); _nodePublishingConfiguration = null; lock (_singletonLock) { _instance = null; } } }
/// <summary> /// Implement IDisposable. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing) { //OpcSessionsListSemaphore.Wait(); avoid get semaphore here, otherwise there will be deadlock during OpcSession disposing foreach (var opcSession in OpcSessions) { opcSession.Dispose(); } OpcSessions?.Clear(); OpcSessionsListSemaphore?.Dispose(); OpcSessionsListSemaphore = null; PublisherNodeConfigurationSemaphore?.Dispose(); PublisherNodeConfigurationSemaphore = null; PublisherNodeConfigurationFileSemaphore?.Dispose(); PublisherNodeConfigurationFileSemaphore = null; _nodePublishingConfiguration?.Clear(); _nodePublishingConfiguration = null; lock (_singletonLock) { _instance = null; } } }