【发布时间】:2010-12-17 09:23:43
【问题描述】:
我正面临一个我似乎无法解决的问题。
private void IndexEntityType(Type targetType, bool onlyNew)
{
Logger.Debug("generating index for {0}", targetType);
using (var wrapper = SessionWrapper.For(targetType, true))
{
var session = wrapper.Session;
session.FlushMode = FlushMode.Never;
session.CacheMode = CacheMode.Ignore;
var entities = GetEntities(targetType, onlyNew, session);
Logger.Debug("Indexing {0} entities", entities.Count);
// Create a Full Text session.
using (var fullTextSession = Search.CreateFullTextSession(session))
using (var transaction = fullTextSession.BeginTransaction())
{
fullTextSession.CacheMode = CacheMode.Ignore;
foreach (var entity in entities)
{
fullTextSession.Index(entity);
}
try
{
transaction.Commit();
}
catch (Exception ex)
{
Logger.Error("could not commit fulltext session transaction", ex);
}
}
Logger.Debug("generated index for {0}", targetType);
}
ReQueueTimers(onlyNew);
}
我正在尝试对此进行调试,并在第一行 (Logger.Debug) 和最后一行 (ReQueueTimers) 设置断点。
但是,在单步执行代码时,永远不会调用最后一次调用 (ReQueueTimers(onlyNew)),也不会遇到断点。怎么可能?编译器是否以某种方式“在优化时将其删除”?
有人对可能触发此行为的原因有任何提示吗?
编辑:如果这可能与它有关,它会在多个线程中运行。
【问题讨论】:
标签: c# multithreading debugging compiler-construction