2

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();
    }
}
4

2 に答える 2

2

リモーティング機能を試してください。見る:

于 2010-03-18T01:49:33.810 に答える
1

別の AppDomain を既に作成している場合、プライベート AppDomain 内に Windsor コンテナーの新しいインスタンスを作成することはできませんか?

于 2010-03-03T03:08:01.240 に答える