Skip to content

Commit 5c5b5aa

Browse files
committed
修复多次写入
1 parent c48c076 commit 5c5b5aa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Code/UsingMSBuildCopyOutputFileToFastDebug/SafeOutputFileCopyTask.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Linq;
6+
using System.Threading.Tasks;
67

78
namespace UsingMSBuildCopyOutputFileToFastDebug
89
{
@@ -79,7 +80,7 @@ public override bool Execute()
7980
return true;
8081
}
8182

82-
private void AddToClean(string newFileName)
83+
private async void AddToClean(string newFileName)
8384
{
8485
// 加入到清理文件
8586

@@ -89,11 +90,15 @@ private void AddToClean(string newFileName)
8990
{
9091
newFileName = Path.GetFullPath(newFileName);
9192
File.AppendAllLines(CleanFile, new[] { newFileName });
93+
94+
return;
9295
}
9396
catch (Exception)
9497
{
9598
// 忽略
9699
}
100+
101+
await Task.Delay(TimeSpan.FromMilliseconds(200));
97102
}
98103
}
99104
}

0 commit comments

Comments
 (0)