- .NET API: fixed bug in DataSet destructor

pull/239/head
Michael Zillgith 5 years ago
parent 9b5c45a0b3
commit 83e8e14603

@ -65,7 +65,8 @@ namespace IEC61850
/// </returns> /// </returns>
public string GetReference() public string GetReference()
{ {
if (reference == null) { if (reference == null)
{
IntPtr nativeString = ClientDataSet_getReference(nativeObject); IntPtr nativeString = ClientDataSet_getReference(nativeObject);
reference = Marshal.PtrToStringAnsi(nativeString); reference = Marshal.PtrToStringAnsi(nativeString);
@ -85,7 +86,8 @@ namespace IEC61850
/// </returns> /// </returns>
public MmsValue GetValues() public MmsValue GetValues()
{ {
if (values == null) { if (values == null)
{
IntPtr nativeValues = ClientDataSet_getValues(nativeObject); IntPtr nativeValues = ClientDataSet_getValues(nativeObject);
values = new MmsValue(nativeValues, false); values = new MmsValue(nativeValues, false);
@ -108,8 +110,10 @@ namespace IEC61850
public void Dispose() public void Dispose()
{ {
lock (this) { lock (this)
if (nativeObject != IntPtr.Zero) { {
if (nativeObject != IntPtr.Zero)
{
ClientDataSet_destroy(nativeObject); ClientDataSet_destroy(nativeObject);
nativeObject = IntPtr.Zero; nativeObject = IntPtr.Zero;
} }
@ -118,7 +122,7 @@ namespace IEC61850
~DataSet() ~DataSet()
{ {
ClientDataSet_destroy (nativeObject); Dispose();
} }
internal IntPtr getNativeInstance() internal IntPtr getNativeInstance()

Loading…
Cancel
Save