public static TriggerAsynchronousFetchStatus TriggerAsynchronousFetch <T>(LoadSerializedObjectDelegate <T> loadObject, string cacheItemName
                                                                                  , string iterationKey, CacheItemContainer cacheItemContainer)
            where T : class
        {
            ContinuousCacheAccessThreadHelper <T> threadHelper;
            Thread thread;

            // we are in the extended lifespan, so we need to check whether we have to reload the object
            if (ContinuousCacheAccessSynchronizationManager.SetIsFetchingDataFlagToTrue(cacheItemContainer.CacheKey))
            {
                #region debug
#if DEBUG
                Trace.WriteLine(DebugConstants.DEBUG_PREFIX + "TRIGGER ASYNCHRONOUS FETCH: Initialize asynchronous fetch");
#endif
                #endregion

                threadHelper = ContinuousCacheAccessThreadHelper <T> .GetInstance(loadObject, cacheItemName, iterationKey);

                thread = new Thread(threadHelper.FetchAndInsertData);
                thread.Start();
                return(TriggerAsynchronousFetchStatus.SucessfullyInitialized);
            }
            else
            {
                #region debug
#if DEBUG
                Trace.WriteLine(DebugConstants.DEBUG_PREFIX + "TRIGGER ASYNCHRONOUS FETCH: Already in process...");
#endif
                #endregion

                return(TriggerAsynchronousFetchStatus.AlreadyFetching);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <param name="loadObject">The load object.</param>
        /// <param name="cacheItemName">Name of the cache item.</param>
        /// <param name="iterationKey">The iteration key.</param>
        /// <returns></returns>
        internal static ContinuousCacheAccessThreadHelper <T> GetInstance(LoadSerializedObjectDelegate <T> loadObject, string cacheItemName, string iterationKey)
        {
            ContinuousCacheAccessThreadHelper <T> record = new ContinuousCacheAccessThreadHelper <T>();

            record._LoadObjectDelegate = loadObject;
            record._CacheItemName      = cacheItemName;
            record._IterationKey       = iterationKey ?? string.Empty;

            return(record);
        }