private void HandleExceptionInTestThread(Guid mdbGuid, EventId id, SearchTestResult result, Exception e) { if (this.CheckForServices(result)) { return; } TestSearch.TestSearchTracer.TraceDebug <Exception>((long)this.GetHashCode(), "got exception {0}", e); string error = SearchCommon.DiagnoseException(result.Server, mdbGuid, e); if (id == EventId.MapiError) { result.SetErrorTestResult(id, Strings.TestSearchMapiError(result.Database, error)); return; } result.SetErrorTestResult(id, Strings.TestSearchActiveManager(result.Database, error)); }
private void SearchForMessage(MessageSearcher messageSearcher, SearchTestResult result) { if (messageSearcher == null) { throw new ArgumentNullException("messageSearcher"); } if (result == null) { throw new ArgumentNullException("result"); } TimeSpan timeout = new TimeSpan(0, 0, 1); DateTime utcNow = DateTime.UtcNow; Exception ex = null; try { this.threadExit.CheckStop(); messageSearcher.InitializeSearch(); bool flag = false; int tickCount = Environment.TickCount; while (!flag) { this.threadExit.CheckStop(); try { flag = messageSearcher.DoSearch(); int tickCount2 = Environment.TickCount; if (flag) { result.SetTestResult(true, new TimeSpan((long)((tickCount2 - tickCount) * 10000)).TotalSeconds); } } catch (MapiRetryableException exception) { this.monitor.PushMessage(SearchCommon.DiagnoseException(result.Server, result.DatabaseGuid, exception)); } this.threadExit.CheckStop(); if (!flag) { Thread.Sleep(timeout); } } } catch (MapiExceptionNotFound mapiExceptionNotFound) { ex = mapiExceptionNotFound; } catch (MapiRetryableException ex2) { ex = ex2; } catch (MapiPermanentException ex3) { ex = ex3; } catch (TestSearchOperationAbortedException) { TestSearch.TestSearchTracer.TraceDebug((long)this.GetHashCode(), "Thread terminated on TestSearchOperationAbortedException"); this.monitor.PushMessage(Strings.TestSearchTestThreadTimeOut); result.SetErrorTestResultWithTestThreadTimeOut(); } finally { if (ex != null) { this.HandleExceptionInTestThread(result.DatabaseGuid, EventId.MapiError, result, ex); } } }