【发布时间】:2013-12-23 11:04:52
【问题描述】:
当我突然发现另一个产品的详细信息最终出现在另一个产品中时,我有不同的产品异步运行。
当我将它传输到另一个服务时,我将它存储在 XML 中。
运行时间:
var transactionScopeOptions = new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted, Timeout = Timeout = new TimeSpan(0, 10, 0) };
using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionScopeOptions))
{
using (var dataContext = new FooContext())
{
/* code goes here, single instance of dataContext per thread */
}
}
使用扩展类(哪里出错):
public static class FooExtensions
{
public static int GetID(this FooClass foo)
{
var result = foo != null ? foo.ID : 0;
return result;
}
}
如果这不是线程安全的,我如何使它成为线程安全的?
编辑:
也可能是发生了内存泄漏,但不确定。
使用 WCF ConcurrencyMode.Multiple 和 InstanceContextMode.Single
【问题讨论】:
标签: multithreading wcf thread-safety msmq