2012-11-25 6 views
3

상속 된 일부 관리되는 C++ 코드를 업데이트하려고했습니다. 어떤 C++도 모르지만 1.1 일 후에는 C# 클래스를 사용했기 때문에 .Net을 둘러 볼 수 있습니다. ConcurrentQueue의를 사용하여 지금까지 내가 했어 좋은 결과를 내 메인 스레드에서 작업자 스레드로 작업을 보내 :관리되는 C++/.net 4.0의 ConcurrentQueue 객체 만들기

fullQueue = gcnew ConcurrentQueue<int>(); 

.. 

fullQueue->Enqueue(someNumber); 

지금은 내가 노동자 더 복잡한 지시 사항을 보낼 수 있도록 실제 개체를 삽입하려고하고 싶습니다. 그러나이 작동하지 않습니다 :

public ref class workUnit 
{ 
    int ptrOffset; 
    System::String^ outputPath; 
    public: 
     workUnit(int offset, System::String^ path) 
     { 
      ptrOffset=offset; 
      outputPath=path; 
     } 
};  

..

ConcurrentQueue test = gcnew ConcurrentQueue<workUnit ^>(); 

내가 얻을 :

'System::Collections::Concurrent::ConcurrentQueue' : use of class generic requires generic argument list 

'System::Collections::Concurrent::ConcurrentQueue::ConcurrentQueue' : the function template cannot convert parameter 1 from type 'System::Collections::Concurrent::ConcurrentQueue<T> ^' 

은 분명히 나는 ​​객체가 큐에 삽입하는 방법에 대한 근본적인 뭔가가있어. 내 머리 속에는 나중에 인스턴스화 할 수있는 클래스 객체에 대한 참조를 보유 할 대기열이 있으므로 CLR은 참조 유형이 무엇인지 알 필요가 있지만 분명히 올바르지 않습니다. 내가 뭘 놓치고 있니?

답변

1

using namespace System::Collections::Concurrent; 

ref class WorkUnit 
{ 
}; 

int main() 
{ 
    ConcurrentQueue<WorkUnit^>^ test = gcnew ConcurrentQueue<WorkUnit^>(); 
} 

당신은 초기화 표현의 양쪽에 제네릭 형식 < WorkUnit ^>를 참조해야합니다 :) 뭔가를 놓친 것 같다.