Skip to content

Commit c980019

Browse files
authored
Merge pull request #50 from watte1997/FixSlaveDisConnect
Fixed disconnect button cannot stop connection.
2 parents 727518e + 4b3f368 commit c980019

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ModbusSlave/ModbusSlave.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@
180180
<Target Name="AfterBuild">
181181
</Target>
182182
-->
183-
</Project>
183+
</Project>

ModbusSlave/SlaveForm.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ private void DoDisconnect()
154154
_uart.Dispose();
155155
_uart = null;
156156
}
157+
158+
if (_socket != null)
159+
{
160+
_socket.Dispose();
161+
_socket = null;
162+
}
163+
157164
if (_thread != null && _thread.IsAlive)
158165
{
159166
if (_thread.Join(2000) == false)
@@ -162,11 +169,6 @@ private void DoDisconnect()
162169
_thread = null;
163170
}
164171
}
165-
if (_socket != null)
166-
{
167-
_socket.Dispose();
168-
_socket = null;
169-
}
170172
}
171173

172174
#endregion

0 commit comments

Comments
 (0)