当我同步执行读取器时,数据网格被正确加载。当我异步执行读取器时,datagrid是空的。下面是代码。同步-作品 async public Task<DataTable> GetDataTableAsync() DataTable result = new DataTable(); SqlDataReader reader = this.Comm.ExecuteReader();result.Loa
=== program[j].state && reader.scanning === program[j].scanning) { //if there is a line of turingcodecellArray[reader.location].content = program[j].print; //change the content of the current cell to thenew value
reader.location
从中可以看出,在调用同步方法时,我不应该仅仅编写Task.Result的包装器。但是,如何不必在异步方法和同步方法之间复制大量代码,因为我们希望在库中保留这两个选项?由于这是库的核心,所以我似乎需要在同步方法和异步方法之间复制大量代码(希望尽可能保持代码干燥)。那么,是否可以将同步包装器仅为Task.Result或Wait()? }
} while (_reader.hasVa