使用TTask :: Future<>在Embarcadero XE7 C ++中

时间:2018-02-01 04:56:14

标签: c++ multithreading

我试图从here制作“教程:使用并行编程库中的未来”。 我创建了项目“文件>新>多设备应用程序 - C ++ Builder>空白应用程序”并从链接复制源。

#include <System.Threading.hpp>

·H

public:     // User declarations
    System::DelphiInterface<IFuture__1<System::String> > FutureString;
    System::String __fastcall FutureHandler(TObject* Sender);

的.cpp

void __fastcall TForm1::Button1Click(TObject *Sender) {
   FutureString = TTask::Future<System::String>(0, this->FutureHandler);
}

System::String __fastcall TForm1::FutureHandler(TObject* Sender) {
  Sleep(3000);
  System::String str = System::String().sprintf(L"Hello %d", Random(42));
  return str;
}

构建后我收到此错误消息:

  

[ilink64 Error]错误:未解析的外部'System :: DelphiInterface&gt; System :: Threading :: TTask :: Future(System :: TObject *,System :: UnicodeString(* __closure)(System :: TObject *))'从C:\ USERS \ PC \ DESKTOP \ 64BIT \ WIN64 \ DEBUG引用\ UNIT1.O

来自 System.Threading.hpp

声明

 template<typename T> static System::DelphiInterface<IFuture__1<T> >
   __fastcall Future(System::TObject* Sender, T __fastcall (__closure *)
    (System::TObject* Sender) )/* overload */;

===

protected:
HIDESBASE System::DelphiInterface<IFuture__1<T> > __fastcall Start(void);
T __fastcall GetValue(void);
#ifndef _WIN64
typedef T __fastcall (__closure *_dt_System_Threading_2)(System::TObject* Sender);
__fastcall TFuture__1(System::TObject* Sender, _dt_System_Threading_2 Event, 
const System::DelphiInterface<System::Sysutils::TFunc__1<T> > Func, TThreadPool* APool)/* overload */;
#else /* _WIN64 */
__fastcall TFuture__1(System::TObject* Sender, TFunctionEvent__1<T> Event, const System::DelphiInterface<System::Sysutils::TFunc__1<T> > Func, TThreadPool* 
APool)/* overload */;
#endif /* _WIN64 */

private:
 // __classmethod void __fastcall Destroy@();
protected:
/* TTask.Create */ inline __fastcall TFuture__1(System::TObject* Sender, 
System::Classes::TNotifyEvent Event, const System::Sysutils::_di_TProc AProc, TThreadPool* const APool, TTask* const AParent, TTask::TCreateFlags CreateFlags)/* overload */ : TTask(Sender, Event, AProc, APool, AParent, CreateFlags) { }

public:
/* TTask.Create */ inline __fastcall TFuture__1(void)/* overload */ : 
TTask() { }
/* TTask.Destroy */ inline __fastcall virtual ~TFuture__1(void) { }

private:
void *__IFuture__1; // IFuture__1<T> 

public:
operator IFuture__1<T>*(void) { return (IFuture__1<T>*)&__IFuture__1; }

};

如何应对此错误?

0 个答案:

没有答案