Skip to content

Commit ed9c482

Browse files
committed
Fixed the bug that the existing task cannot be stopped after clicking the modbus slave disconnect button
1 parent 727518e commit ed9c482

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ModbusSlave/ModbusSlave.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
</Compile>
135135
<EmbeddedResource Include="SlaveForm.resx">
136136
<DependentUpon>SlaveForm.cs</DependentUpon>
137+
<SubType>Designer</SubType>
137138
</EmbeddedResource>
138139
<None Include="app.config" />
139140
<None Include="Properties\Settings.settings">

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)