每当我尝试调试我的代码时,我都会得到错误,但是我无法继续。
AsyncMethodBuilder.cs未找到
背景信息:
我必须压缩大量的文档,并且要花费最少的时间。我有一个压缩库,并且能够同步进行压缩。但是为了加快速度,我想并行压缩文档(一次压缩的文档不是可编程的),这样我就可以适当地利用CPU,并在最佳的时间完成工作。
为了实现上述目标,我按照this链接创建多个任务并等待它们完成
下面是我尝试过的代码。
public static class CompressAllTechniques
{
public static void Main()
{
GoCallAPIAsync();
}
private static async void GoCallAPIAsync()
{
try
{
List<Task> TaskList = new List<Task>();
// For Sample testing I have taken 4 files and will iterate through them to check the timings
const string originalFile1 = @"Sample Data\source";
const string originalFile2 = @"Sample Data\source1";
const string originalFile3 = @"Sample Data\Original";
const string originalFile4 = @"Sample Data\Original1";
List<string> arr = new List<string>() { originalFile1, originalFile2, originalFile3, originalFile4 };
int noofThreads = 2; // No of tasks that has to run paralally
int IterationsCompleted = 0;
int TotalIterations = 10;
var temp = arr;
Console.WriteLine("\n\nProcess Started @ " + DateTime.Now);
for (int i = 0; i < TotalIterations; i++)
{
if (temp.Count == 0) temp = arr;
var sd = temp.Take(noofThreads);
foreach (var item in sd)
{
var LastTask = new Task(() => GoCompress(item, IterationsCompleted));
LastTask.Start();
TaskList.Add(LastTask);
}
temp = temp.Except(sd).ToList();
await Task.WhenAll(TaskList.ToArray());
TaskList.Clear();
}
Console.WriteLine("\n\nProcess Completed @ " + DateTime.Now);
Console.Read();
}
catch (Exception ex)
{
throw;
}
}
private static void GoCompress(string zdf, int dcnk)
{
// Compression Logic
}
}
当我尝试调试上面的代码时,我在Visual中得到了以下异常。
Locating source for 'f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\AsyncMethodBuilder.cs'. (No checksum.)
The file 'f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\AsyncMethodBuilder.cs' does not exist.
Looking in script documents for 'f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\AsyncMethodBuilder.cs'...
Looking in the projects for 'f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\AsyncMethodBuilder.cs'.
The file was not found in a project.
发布于 2020-10-27 19:21:47
就像@stuartd在上面的注释中说的那样,为调试选项“只启用我的代码”启用(复选框):
我是从谷歌来到这里的,虽然这看起来没有帮助@Sashi,但它解决了我的机器上的这个错误。
https://stackoverflow.com/questions/58349438
复制相似问题