我在 Windows XP 32位虚拟机上测试我的一些代码时发现了一些问题:我的应用程序始终处于挂起状态。我的 Windows 7 64位计算机上从未出现过这种现象,但在VM上可以100%重现。
通过远程调试,我发现程序挂在IOmniTaskControl.WaitForInit
的调用上。我在TOmniWorker.Initialize
中设置了断点,但没有触发。
这是我创建任务的方法:
constructor TThreadedImportCache.Create(
const AImportCacheConstructorParams: TImportCacheConstructorParamsWrapper);
begin
inherited Create;
FIsFlushingCounter := CreateCounter;
FWorker := TImportCacheWorker.Create(AImportCacheConstructorParams, FIsFlushingCounter);
FTaskControl := CreateTask(FWorker, BuildUniqueIdent(TImportCacheWorker.ClassName));
FTaskControl.Unobserved;
FTaskControl.Schedule;
end;
当我用FTaskControl.Schedule
替换FTaskControl.Run
时,任务被初始化,运行正常,我的应用程序不会冻结。
我的问题:
我是否一直在滥用Schedule
电话?我认为这是一个使用的,因为它不等待实际运行,并且任务在很短的时间后启动。它应该如何使用?
或
这是否与Windows XP上的线程(通过 OmniThreadLibrary )有些问题/不兼容?