Reputation: 5019
I have method that contain parameter BlockingCollection<T>
queue, and T must extend my class QueueItem (it's work fine without the generic).
private void ProcessQueue<T>(BlockingCollection<T> queue) where T: QueueItem
{
QueueItem frame;
while (true)
{
if (queue.TryTake(out frame, -1))
{
frame.execute();
}
}
}
The compilation error on if (queue.TryTake(out frame, -1))
: "the method has some invalid arguments
Why?
Edit the method definition is:
BlockingCollection<T> TryTake(T, Int32)
Upvotes: 0
Views: 49
Reputation: 144206
frame
should be a T
but you are providing a QueueItem
. Change the type of frame
:
T frame;
while (true)
{
if (queue.TryTake(out frame, -1))
{
frame.execute();
}
}
Upvotes: 4