当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.Dispose方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:63,代码来源:LuceneBackendQueueProcessor.cs


注:本文中的Workspace.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。