Removes all elements from the Cache asynchronously.

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.1.0.0 (4.1.0.0)

Syntax

C#
public virtual void ClearAsync(
	DSWriteOption updateOpt,
	AsyncCacheClearedCallback onAsyncCacheClearCallback,
	DataSourceClearedCallback dataSourceClearedCallback
)
Visual Basic
Public Overridable Sub ClearAsync ( _
	updateOpt As DSWriteOption, _
	onAsyncCacheClearCallback As AsyncCacheClearedCallback, _
	dataSourceClearedCallback As DataSourceClearedCallback _
)
Visual C++
public:
virtual void ClearAsync(
	DSWriteOption updateOpt, 
	AsyncCacheClearedCallback^ onAsyncCacheClearCallback, 
	DataSourceClearedCallback^ dataSourceClearedCallback
)

Remarks

This is similar to Clear()()()() except that the operation is performed asynchronously. A CacheCleared event is fired upon successful completion of this method.It is not possible to determine if the actual operation has failed, therefore use this operation for the cases when it does not matter much.

Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.

A delegate that, if provided, is called when data source is cleared.A delegate that, that can be used to get the result of the Asynchronous Clear operation.Options regarding updating data source

Examples

The following example demonstrates how to clear the Cache.
CopyC#
OnDataSourceCleared(object result)
{
...
}

void OnAsyncCacheCleared(object result)
{
...
}
Cache cache = NCache.InitializeCache("myCache");
cache.ClearAsync(DSWriteOption.WriteBehind, new AsyncCacheClearedCallback(OnAsyncCacheCleared), new DataSourceClearedCallback(OnDataSourceCleared));

See Also