I usually use
to clear the cache for the current thread.
Recently I noticed that this was no longer working inside NUnit tests - I think this co-incided with NUnit changing their threading system
I notice in the comments it says that
.. will not work if the Thread has a name - this turns out to be the case for NUnit
in which case should I use this instead:
string threadName = Thread.CurrentThread.Name;
Does that method (Clear( scopeDelimiter )) just clear the specified thread? Or does it do something else?
I don't want to clear anything more than the specified thread - that could be disastrous
(NB: I am using <UniqingScope>Thread</UniqingScope>, obviously, and Gentle 220.127.116.116)
Although it's been some time since I wrote this, the caching code seems to have been written with named threads in mind. That is, if the thread has a name then that is actually used as the scopeDelimiter in preference of the threads id (you can verify this in the SystemSettings.ThreadIdentity property getter, which is called from the CacheManager.GetScopeDelimiter method).
As such, calling CacheManager.Clear( Thread.CurrentThread.Name ) should work fine. However, calling CacheManager.Clear( SystemSettings.ThreadIdentity ) would work even when the thread has not been assigned a name.
Hope this helps :)
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.