Lucene.Net.Index.TestIndexWriterExceptions.IndexerThread.Run C# (CSharp) Method

Run() public method

public Run ( ) : void
return void
			override public void  Run()
			{
				
				Document doc = new Document();

                doc.Add(new Field("content1", "aaa bbb ccc ddd", Field.Store.YES, Field.Index.ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));
                doc.Add(new Field("content6", "aaa bbb ccc ddd", Field.Store.NO, Field.Index.ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));
                doc.Add(new Field("content2", "aaa bbb ccc ddd", Field.Store.YES, Field.Index.NOT_ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));
				doc.Add(new Field("content3", "aaa bbb ccc ddd", Field.Store.YES, Field.Index.NO));

                doc.Add(new Field("content4", "aaa bbb ccc ddd", Field.Store.NO, Field.Index.ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));
                doc.Add(new Field("content5", "aaa bbb ccc ddd", Field.Store.NO, Field.Index.NOT_ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));

                doc.Add(new Field("content7", "aaa bbb ccc ddd", Field.Store.NO, Field.Index.NOT_ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random)));

                Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED, enclosingInstance.RandomTVSetting(enclosingInstance.random));
				doc.Add(idField);
				
				long stopTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + 3000;
				
				while ((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) < stopTime)
				{
					System.Threading.Thread.SetData(Enclosing_Instance.doFail, this);
					System.String id = "" + r.Next(50);
					idField.SetValue(id);
					Term idTerm = new Term("id", id);
					try
					{
						writer.UpdateDocument(idTerm, doc);
					}
					catch (System.SystemException re)
					{
						if (Lucene.Net.Index.TestIndexWriterExceptions.DEBUG)
						{
							System.Console.Out.WriteLine(ThreadClass.CurrentThread().Name + ": EXC: ");
							System.Console.Out.WriteLine(re.StackTrace);
						}
						try
						{
							_TestUtil.CheckIndex(writer.Directory);
						}
						catch (System.IO.IOException ioe)
						{
							System.Console.Out.WriteLine(ThreadClass.Current().Name + ": unexpected exception1");
							System.Console.Out.WriteLine(ioe.StackTrace);
							failure = ioe;
							break;
						}
					}
					catch (System.Exception t)
					{
						System.Console.Out.WriteLine(ThreadClass.Current().Name + ": unexpected exception2");
						System.Console.Out.WriteLine(t.StackTrace);
						failure = t;
						break;
					}
					
					System.Threading.Thread.SetData(Enclosing_Instance.doFail, null);
					
					// After a possible exception (above) I should be able
					// to add a new document without hitting an
					// exception:
					try
					{
						writer.UpdateDocument(idTerm, doc);
					}
					catch (System.Exception t)
					{
						System.Console.Out.WriteLine(ThreadClass.Current().Name + ": unexpected exception3");
						System.Console.Out.WriteLine(t.StackTrace);
						failure = t;
						break;
					}
				}
			}
		}
TestIndexWriterExceptions.IndexerThread