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


C# ThreadClass.Start方法代码示例

本文整理汇总了C#中Lucene.Net.Support.ThreadClass.Start方法的典型用法代码示例。如果您正苦于以下问题:C# ThreadClass.Start方法的具体用法?C# ThreadClass.Start怎么用?C# ThreadClass.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Support.ThreadClass的用法示例。


在下文中一共展示了ThreadClass.Start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

		public virtual void  Init(IndexReader reader)
		{
			this.reader = reader;
			timeElapsed = 0;
			t = new ThreadClass(new System.Threading.ThreadStart(this.Run));
			t.Start();
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:7,代码来源:TestMultiThreadTermVectors.cs

示例2: Start

        protected internal virtual void Start(int numNodes, double runTimeSec, int maxSearcherAgeSeconds)
        {
            EndTime = DateTime.UtcNow.AddSeconds(runTimeSec);
            this.MaxSearcherAgeSeconds = maxSearcherAgeSeconds;

            Nodes = new NodeState[numNodes];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                Nodes[nodeID] = new NodeState(this, Random(), nodeID, numNodes);
            }

            long[] nodeVersions = new long[Nodes.Length];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = Nodes[nodeID].Mgr.Acquire();
                try
                {
                    nodeVersions[nodeID] = Nodes[nodeID].Searchers.Record(s);
                }
                finally
                {
                    Nodes[nodeID].Mgr.Release(s);
                }
            }

            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = Nodes[nodeID].Mgr.Acquire();
                Debug.Assert(nodeVersions[nodeID] == Nodes[nodeID].Searchers.Record(s));
                Debug.Assert(s != null);
                try
                {
                    BroadcastNodeReopen(nodeID, nodeVersions[nodeID], s);
                }
                finally
                {
                    Nodes[nodeID].Mgr.Release(s);
                }
            }

            ChangeIndicesThread = new ChangeIndices(this);
            ChangeIndicesThread.Start();
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:43,代码来源:ShardSearchingTestBase.cs

示例3: TestIntermediateClose

 public virtual void TestIntermediateClose()
 {
     Directory dir = NewDirectory();
     // Test can deadlock if we use SMS:
     IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergeScheduler(new ConcurrentMergeScheduler()));
     writer.AddDocument(new Document());
     writer.Commit();
     CountdownEvent awaitEnterWarm = new CountdownEvent(1);
     CountdownEvent awaitClose = new CountdownEvent(1);
     AtomicBoolean triedReopen = new AtomicBoolean(false);
     //TaskScheduler es = Random().NextBoolean() ? null : Executors.newCachedThreadPool(new NamedThreadFactory("testIntermediateClose"));
     TaskScheduler es = Random().NextBoolean() ? null : TaskScheduler.Default;
     SearcherFactory factory = new SearcherFactoryAnonymousInnerClassHelper2(this, awaitEnterWarm, awaitClose, triedReopen, es);
     SearcherManager searcherManager = Random().NextBoolean() ? new SearcherManager(dir, factory) : new SearcherManager(writer, Random().NextBoolean(), factory);
     if (VERBOSE)
     {
         Console.WriteLine("sm created");
     }
     IndexSearcher searcher = searcherManager.Acquire();
     try
     {
         Assert.AreEqual(1, searcher.IndexReader.NumDocs);
     }
     finally
     {
         searcherManager.Release(searcher);
     }
     writer.AddDocument(new Document());
     writer.Commit();
     AtomicBoolean success = new AtomicBoolean(false);
     Exception[] exc = new Exception[1];
     ThreadClass thread = new ThreadClass(() => new RunnableAnonymousInnerClassHelper(this, triedReopen, searcherManager, success, exc).Run());
     thread.Start();
     if (VERBOSE)
     {
         Console.WriteLine("THREAD started");
     }
     awaitEnterWarm.Wait();
     if (VERBOSE)
     {
         Console.WriteLine("NOW call close");
     }
     searcherManager.Dispose();
     awaitClose.Signal();
     thread.Join();
     try
     {
         searcherManager.Acquire();
         Assert.Fail("already closed");
     }
     catch (AlreadyClosedException ex)
     {
         // expected
     }
     Assert.IsFalse(success.Get());
     Assert.IsTrue(triedReopen.Get());
     Assert.IsNull(exc[0], "" + exc[0]);
     writer.Dispose();
     dir.Dispose();
     //if (es != null)
     //{
     //    es.shutdown();
     //    es.awaitTermination(1, TimeUnit.SECONDS);
     //}
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:65,代码来源:TestSearcherManager.cs


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