예제 #1
0
        static public void ReleaseCachedFeatureCollection(ICachedFeatureCollection cachedFeatureColledion)
        {
            CachedFeatureCollection collection = cachedFeatureColledion as CachedFeatureCollection;

            if (collection != null)
            {
                collection.Released = true;
            }
        }
예제 #2
0
 static public ICachedFeatureCollection CreateCachedFeatureCollection(Guid guid, IQueryFilter filter, int LifeTime)
 {
     lock (lockThis)
     {
         CachedFeatureCollection collection;
         if (_collections.TryGetValue(guid, out collection))
         {
             return(null);
         }
         else
         {
             collection = new CachedFeatureCollection(guid, filter);
             _collections.Add(guid, collection);
             return(collection);
         }
     }
 }
예제 #3
0
        static public ICachedFeatureCollection GetUsableFeatureCollection(Guid guid, IQueryFilter filter)
        {
            CachedFeatureCollection collection = GetCachedFeatureCollection(guid) as CachedFeatureCollection;

            if (collection == null || !collection.UsableWith(filter))
            {
                return(null);
            }

            if (collection.Released)
            {
                return(collection);
            }
            else
            {
                //
                // Wait for release!!! (Hope there is no deadlocking)
                //

                if (Thread.CurrentThread != collection._myThread)
                {
                    ManualResetEvent resetEvent = new ManualResetEvent(false);
                    collection._resetEvents.Add(resetEvent);
                    resetEvent.WaitOne(10000, false);
                    if (collection.Released)
                    {
                        return(collection);
                    }
                }
                else
                {
                    throw new Exception("Can't use unreleased cached featurecollection\nWaiting thread is identical with work thread!\nDeadlocking situation!");
                }
            }
            return(null);
        }