Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ReportProgress 的最佳位置是什么?
//Do my hard work before report progress bkWorker.ReportProgress((int)percent, company.CompanyName);
或者
bkWorker.ReportProgress((int)percent, company.CompanyName); //Do my hard work after report progress
从时序的角度来看,这无关紧要,因为循环的顶部或底部会发生得如此之快。
只需确保覆盖边缘情况(从一开始就设置 0%,完成后设置 100%。您的选项如下:
while(condition) { report dowork } report 100%
report 0% while(condition) { dowork report }
while(true) { report if(100%) break; dowork }
因此,这取决于您对逻辑外观的偏好。处理时间无关紧要