These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Exception: Found shared references to a collection
PostPosted: Sun Jul 22, 2007 4:28 am 
Beginner
Beginner

Joined: Mon Sep 26, 2005 5:57 pm
Posts: 39
Please consider this code which works fine:
Code:
IList lstCRCS = claimreviewcyclestatus.get_all_statuses_for_which_document_generation_is_pending();
               
foreach (claimreviewcyclestatus crcs in lstCRCS)
{
     crcs.GenerateDocuments();
}


The above code works fine. claimreviewcyclestatus is a persistent class.

However, I wanted to some multi-threading, and for each individual claimreviewcyclestatus object, generate documents on a separate thread. So I changed the code and for the sake of brevity, I am posting only the relevant code:
Code:
CountedEvent jobFinished = new CountedEvent();

                IList lstCRCS = claimreviewcyclestatus.get_all_statuses_for_which_document_generation_is_pending();
               
                foreach (claimreviewcyclestatus crcs in lstCRCS)
                {
                    jobFinished.Reset();

                    my_state ms = new my_state();
                    ms.CountedEvent = jobFinished;
                    ms.Claimreviewcyclestatus = crcs;
                    ThreadPool.QueueUserWorkItem(new WaitCallback(worker_DoWork), ms);
                }

                jobFinished.WaitOne();


This is classic Threadppol.QueueworkItem code. But I immediately get an exception: Found shared references to a collection: CID.IPath.NewBusinessLayer.claimreview.col_claimreviewcyclestatus.

claimreview.col_claimreviewcyclestatus is a persistent collection as well.

What am I doing wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.