This commit is contained in:
parallelbgls
2016-09-20 11:04:54 +08:00
parent 55f842f9b1
commit fc693ebd8a

View File

@@ -511,6 +511,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private async Task MaintainTasks2Async() private async Task MaintainTasks2Async()
{
try
{ {
var tasks = new List<Task>(); var tasks = new List<Task>();
HashSet<BaseMachine> saveMachines = new HashSet<BaseMachine>(); HashSet<BaseMachine> saveMachines = new HashSet<BaseMachine>();
@@ -518,8 +520,6 @@ namespace Modbus.Net
{ {
saveMachines.UnionWith(_unlinkedMachines); saveMachines.UnionWith(_unlinkedMachines);
} }
try
{
foreach (var machine in saveMachines) foreach (var machine in saveMachines)
{ {
CancellationTokenSource cts = new CancellationTokenSource(); CancellationTokenSource cts = new CancellationTokenSource();
@@ -527,7 +527,7 @@ namespace Modbus.Net
var task = _tasks.StartNew(() => RunTask(machine).WithCancellation(cts.Token)); var task = _tasks.StartNew(() => RunTask(machine).WithCancellation(cts.Token));
tasks.Add(task); tasks.Add(task);
} }
await Task.WhenAll(); await Task.WhenAll(tasks);
} }
catch catch
{ {