NET Caching Library Help
IsBusy Property (SmartCache)
Example 




KellermanSoftware.NetCachingLibrary Namespace > SmartCache Class : IsBusy Property
Returns true when scavenging or async save or delete is in process for the Secondary Provider
Syntax
'Declaration
 
Public ReadOnly Property IsBusy As System.Boolean
'Usage
 
Dim instance As SmartCache
Dim value As System.Boolean
 
value = instance.IsBusy
public System.bool IsBusy {get;}
public: __property System.bool get_IsBusy();
public:
property System.bool IsBusy {
   System.bool get();
}
Example
//Create a file cache with async set and remove
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests");
FileCacheProvider fileCacheProvider = new FileCacheProvider(directory);
fileCacheProvider.IsAsyncSetAndRemove = true;
 
SmartConfig config = new SmartConfig(new MemoryCacheProvider(), fileCacheProvider);
 
//Specify UserName and LicenseKey for Licensed Mode
//config.UserName = "my user name";
//config.LicenseKey = "my license key";
 
//Instantiate the cache
SmartCache cache = new SmartCache(config);
 
//Save 12 months asynchronously
for(int i = 1; i <= 12;i++)
{
    string cacheKey = string.Format("FlushTest-{0}", i);
 
    //Get a long running report
    List<ReportDetail> report = ReportLogic.MonthlySalesReport(i, DateTime.Now.Year - 1);
 
    //Save to the cache asynchronously
    cache.Set<List<ReportDetail>>(cacheKey, report);
}
 
//Flush the cache
cache.Flush(5);
 
//This will be false since we flushed
Console.WriteLine(cache.IsBusy);
'Create a file cache with async set and remove
Dim directory As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests")
Dim fileCacheProvider As New FileCacheProvider(directory)
fileCacheProvider.IsAsyncSetAndRemove = True
 
Dim config As New SmartConfig(New MemoryCacheProvider(), fileCacheProvider)
 
'Specify UserName and LicenseKey for Licensed Mode
'config.UserName = "my user name";
'config.LicenseKey = "my license key";
 
'Instantiate the cache
Dim cache As New SmartCache(config)
 
'Save 12 months asynchronously
For i As Integer = 1 To 12
    Dim cacheKey As String = String.Format("FlushTest-{0}", i)
 
    'Get a long running report
    Dim report As List(Of ReportDetail) = ReportLogic.MonthlySalesReport(i, Date.Now.Year - 1)
 
    'Save to the cache asynchronously
    cache.Set(Of List(Of ReportDetail))(cacheKey, report)
Next i
 
'Flush the cache
cache.Flush(5)
 
'This will be false since we flushed
Console.WriteLine(cache.IsBusy)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SmartCache Class
SmartCache Members