TOmniTaskControl:.Run与.Schedule在WinXP上

时间:2015-01-02 15:23:51

标签: delphi windows-xp omnithreadlibrary

我在 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时,任务被初始化,运行正常,我的应用程序不会冻结。

我的问题:

  1. 我是否一直在滥用Schedule电话?我认为这是一个使用的,因为它不等待实际运行,并且任务在很短的时间后启动。它应该如何使用?

  2. 这是否与Windows XP上的线程(通过 OmniThreadLibrary )有些问题/不兼容?

0 个答案:

没有答案