From b2f417bdbf069df595e0c5eb8d2b5ef1768c8bdf Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Sun, 18 Apr 2021 16:35:51 +0200 Subject: [PATCH 1/2] - updated comments and readme --- README.md | 10 ++++++++++ dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 387a87a3..cee30b14 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,16 @@ Depending on the system you don't have to provide a generator to the cmake comma To select some configuration options you can use ccmake or cmake-gui. +For newer version of Visual Studio you can use one of the following commands (for 64 bit builds): + +For Visual Studio 2017: + + cmake -G "Visual Studio 15 2017 Win64" .. + +For Visual Studio 2019 (new way to specify the x64 platform): + + cmake -G "Visual Studio 16 2019" .. -A x64 + ## Using the log service with sqlite diff --git a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs index aff8fc67..29315143 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs @@ -548,7 +548,7 @@ namespace IEC61850 /// /// Called when there is a change in the connection state /// - public delegate void StateChangedHandler(IedConnection connection,IedConnectionState newState); + public delegate void StateChangedHandler(IedConnection connection, IedConnectionState newState); [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedConnection_installStateChangedHandler(IntPtr connection, InternalStateChangedHandler handler, IntPtr parameter); @@ -1788,7 +1788,7 @@ namespace IEC61850 /// by a prior function call. /// The user provided callback handler /// This exception is thrown if there is a connection or service error - [Obsolete("ConnectionClosedHandler is deprecated, please use ConnectionEventHandler instead")] + [Obsolete("ConnectionClosedHandler is deprecated, please use StateChangedHandler instead")] public void InstallConnectionClosedHandler(ConnectionClosedHandler handler) { if (connectionClosedHandler == null) From efe4513d11b0a2f56c49e63f914accb327d6405e Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Sun, 18 Apr 2021 16:56:45 +0200 Subject: [PATCH 2/2] - .NET API: fully implemented dispose pattern in DataSet class --- dotnet/IEC61850forCSharp/DataSet.cs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/dotnet/IEC61850forCSharp/DataSet.cs b/dotnet/IEC61850forCSharp/DataSet.cs index 2fcb1040..d7304bc9 100644 --- a/dotnet/IEC61850forCSharp/DataSet.cs +++ b/dotnet/IEC61850forCSharp/DataSet.cs @@ -34,6 +34,11 @@ namespace IEC61850 /// This class is used to represent a data set. It is used to store the values /// of a data set. /// + /// + /// This class manages native resource. Take care that the finalizer/Dispose is not + /// called while running a method or the object is still in use by another object. + /// If in doubt please use the "using" statement. + /// public class DataSet : IDisposable { [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] @@ -108,21 +113,34 @@ namespace IEC61850 return ClientDataSet_getDataSetSize(nativeObject); } - public void Dispose() + private bool disposed = false; + + protected virtual void Dispose(bool disposing) { lock (this) { - if (nativeObject != IntPtr.Zero) + if (!disposed) { - ClientDataSet_destroy(nativeObject); - nativeObject = IntPtr.Zero; + if (nativeObject != IntPtr.Zero) + { + ClientDataSet_destroy(nativeObject); + nativeObject = IntPtr.Zero; + } + + disposed = true; } } } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + ~DataSet() { - Dispose(); + Dispose(false); } internal IntPtr getNativeInstance()