本文整理汇总了C#中Workspace.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.Dispose方法的具体用法?C# Workspace.Dispose怎么用?C# Workspace.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
///
/// </summary>
/// <param name="ignore">Ignored, used to keep the delegate signature that WaitCallback requires</param>
public void Run(object ignore)
{
Workspace workspace = new Workspace(searchFactoryImplementor);
LuceneWorker worker = new LuceneWorker(workspace);
try
{
List<LuceneWorker.WorkWithPayload> queueWithFlatDPs = new List<LuceneWorker.WorkWithPayload>(queue.Count*2);
foreach (LuceneWork work in queue)
{
DocumentBuilder documentBuilder = searchFactoryImplementor.DocumentBuilders[work.EntityClass];
IIndexShardingStrategy shardingStrategy = documentBuilder.DirectoryProvidersSelectionStrategy;
if (work is PurgeAllLuceneWork)
{
IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForDeletion(work.EntityClass, work.Id, work.IdInString);
foreach (IDirectoryProvider provider in providers)
{
queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider));
}
}
else if (work is AddLuceneWork)
{
IDirectoryProvider provider = shardingStrategy.GetDirectoryProviderForAddition(work.EntityClass, work.Id, work.IdInString, work.Document);
queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider));
}
else if (work is DeleteLuceneWork)
{
IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForDeletion(work.EntityClass, work.Id, work.IdInString);
foreach (IDirectoryProvider provider in providers)
{
queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider));
}
}
else if (work is OptimizeLuceneWork)
{
IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForAllShards();
foreach (IDirectoryProvider provider in providers)
{
queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider));
}
}
else
{
throw new AssertionFailure("Unknown work type: " + work.GetType());
}
}
DeadLockFreeQueue(queueWithFlatDPs);
CheckForBatchIndexing(workspace);
foreach (LuceneWorker.WorkWithPayload luceneWork in queueWithFlatDPs)
{
worker.PerformWork(luceneWork);
}
}
finally
{
workspace.Dispose();
queue.Clear();
}
}