Search Results

Search found 5 results on 1 pages for 'user43838'.

Page 1/1 | 1 

  • Do something else if ReadWriteSlimlock is held

    - by user43838
    Hi everyone, I have implemented ReaderWriterLockSlim, Now i don't want it to wait at the lock. I want to do something else if the lock is held. I considered using is isWriterLockHeld but it does not makes much sense to me, Since if two threads come in at the same time and enter the if statement at the same time one will still be waiting at the lock here is my code. ReaderWriterLockSlim rw = GetLoadingLock(parameters); rw = GetLoadingLock(parameters); try { rw.EnterWriteLock(); item = this.retrieveCacheItem(parameters.ToString(), false); if (item != null) { parameters.DataCameFromCache = true; // if the data was found in the cache, return it immediately return item.data; } else { try { object loaditem = null; itemsLoading[parameters.ToString()] = true; loaditem = this.retrieveDataFromStore(parameters); return loaditem; } finally { itemsLoading.Remove(parameters.ToString()); } } } finally { rw.ExitWriteLock(); } Can anyone please guide me in the right direction with this. Thanks

    Read the article

  • Not Able to call The method Asynchronously in the Unit Test.

    - by user43838
    Hi everyone, I am trying to call a method that passes an object called parameters. public void LoadingDataLockFunctionalityTest() { DataCache_Accessor target = DataCacheTest.getNewDataCacheInstance(); target.itemsLoading.Add("WebFx.Caching.TestDataRetrieverFactorytestsync", true); DataParameters parameters = new DataParameters("WebFx.Core", "WebFx.Caching.TestDataRetrieverFactory", "testsync"); parameters.CachingStrategy = CachingStrategy.TimerDontWait; parameters.CacheDuration = 0; string data = (string)target.performGetForTimerDontWaitStrategy(parameters); TestSyncDataRetriever.SimulateLoadingForFiveSeconds = true; Thread t1 = new Thread(delegate() { string s = (string)target.performGetForTimerDontWaitStrategy(parameters); Console.WriteLine(s ?? String.Empty); }); t1.Start(); t1.Join(); Thread.Sleep(1000); ReaderWriterLockSlim rw = DataCache_Accessor.GetLoadingLock(parameters); Assert.IsTrue(rw.IsWriteLockHeld); Assert.IsNotNull(data); } My test is failing all the time and i am not able step through the method.. Can someone please put me in the right direction Thanks

    Read the article

1