diff --git a/dotnet/IEC61850forCSharp/DataSet.cs b/dotnet/IEC61850forCSharp/DataSet.cs index c0c887e9..4a1e0fb0 100644 --- a/dotnet/IEC61850forCSharp/DataSet.cs +++ b/dotnet/IEC61850forCSharp/DataSet.cs @@ -1,7 +1,7 @@ /* * DataSet.cs * - * Copyright 2014 Michael Zillgith + * Copyright 2014-2018 Michael Zillgith * * This file is part of libIEC61850. * @@ -34,7 +34,7 @@ namespace IEC61850 /// This class is used to represent a data set. It is used to store the values /// of a data set. /// - public class DataSet + public class DataSet : IDisposable { [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void ClientDataSet_destroy (IntPtr self); @@ -91,7 +91,7 @@ namespace IEC61850 values = new MmsValue (nativeValues, false); } - return values; + return values.Clone(); } @@ -106,6 +106,16 @@ namespace IEC61850 return ClientDataSet_getDataSetSize (nativeObject); } + public void Dispose() + { + lock (this) { + if (nativeObject != IntPtr.Zero) { + ClientDataSet_destroy (nativeObject); + nativeObject = IntPtr.Zero; + } + } + } + ~DataSet () { ClientDataSet_destroy (nativeObject); diff --git a/dotnet/IEC61850forCSharp/ReportControlBlock.cs b/dotnet/IEC61850forCSharp/ReportControlBlock.cs index 9e6daecf..1854480f 100644 --- a/dotnet/IEC61850forCSharp/ReportControlBlock.cs +++ b/dotnet/IEC61850forCSharp/ReportControlBlock.cs @@ -34,6 +34,8 @@ namespace IEC61850 /// /// Report handler. /// + /// represents the received report. DON'T use this object + /// outside the scope of the report handler! public delegate void ReportHandler (Report report, object parameter); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] diff --git a/dotnet/IEC61850forCSharp/Reporting.cs b/dotnet/IEC61850forCSharp/Reporting.cs index 398db95a..8b72f089 100644 --- a/dotnet/IEC61850forCSharp/Reporting.cs +++ b/dotnet/IEC61850forCSharp/Reporting.cs @@ -293,7 +293,7 @@ namespace IEC61850 values = new MmsValue(dataSetValues); } - return values; + return values.Clone(); } ///