0

I have a concurrentqueue which contains class objects, I want to take those objects and put them into a observable collection of the same class object. (basically copying/moving it from the concurrentqueue to the collection.)

Here I add the elements into the concurrent queue during a multithreaded process.

sTumblrblog_gv_concurqueue.Enqueue(new sTumblrblog_gv() { Title = tumblrusrfollow.Title, Url = tumblrusrfollow.Url.ToString(), AvatarImage = imageavatar, BlogPosts = blogposts, IsNsfw = blogisnfw });

And then I want to take them out of that and put them into an observable collection. Without any duplicate objects (or objects with the same url in them.

if (!sTumblrblog_gv_list.Any(p => p.Url == tumblrusrfollow.Url))
{
     sTumblrblog_gv Queue2ObsCollection =  new Queue2ObsCollection;
     Queue2ObsCollection =(sTumblrblog_gv)sTumblrblog_gv_concurqueue.TryDequeue();
     sTumblrblog_gv_list.Add(new sTumblrblog_gv() { Title = Queue2ObsCollection.Title , Url = Queue2ObsCollection.Url, AvatarImage = Queue2ObsCollection.AvatarImage, BlogPosts = Queue2ObsCollection.BlogPosts, IsNsfw = Queue2ObsCollection.IsNsfw});       
}

I currently get "Error CS1526 A new expression requires (), [], or {} after type" This probably isn't the best way to do this and any thoughts are welcome.

Romasz
  • 29,662
  • 13
  • 79
  • 154
user3395025
  • 135
  • 2
  • 7
  • In your code I think the line `sTumblrblog_gv Queue2ObsCollection = new Queue2ObsCollection;` should be `sTumblrblog_gv Queue2ObsCollection = new sTumblrblog_gv();` (or using other constructor). – Romasz Oct 24 '15 at 06:28
  • When I try that and clean/rebuild I get just the 1 error Error CS7036 There is no argument given that corresponds to the required formal parameter 'result' of 'ConcurrentQueue.TryDequeue(out MainPage.sTumblrblog_gv)' – user3395025 Oct 24 '15 at 12:44

0 Answers0