Castle Windsor を使用してコンポーネントを作成し、個別のスレッドで実行するマルチスレッド サービスを作成しました。I 各スレッドのパラメーターを使用して名前でコンポーネントを解決します。
コンポーネントで使用されるサードパーティ ライブラリで同時実行の問題が発生しています。これらのコンポーネントを別の AppDomains に分離することで問題が解決すると思われます。
別の AppDomain を使用して Resolve にコンポーネントを作成させる方法はありますか?
private ActivityThread NewActivityThread(ActivityInstance activityInstance)
{
// Set up the creation arguments.
System.Collections.IDictionary arguments = new Dictionary<string, string>();
activityInstance.Parameters.ForEach(p => arguments.Add(p.Name, p.Value));
// Get the activity handler from the container.
IActivity activity = Program.Container.Resolve<IActivity>(activityInstance.Name, arguments);
// Create a thread for the activity.
ActivityThread thread = new ActivityThread(activity, activityInstance, _nextActivityID++);
return thread;
}
public ActivityThread(IActivity activity, ActivityInstance instance, int id)
{
_activity = activity;
_instance = instance;
_id = id;
}
public void Start()
{
if (_thread == null)
{
// Create a new thread to run this activity.
_thread = new Thread(delegate() { _activity.Run(); });
_thread.Name = _activity.ToString();
_thread.SetApartmentState(ApartmentState.STA);
_thread.Start();
}
}