2009-08-25 7 views
2

Castle Windsorを使用して別のスレッドで実行するコンポーネントを作成するマルチスレッドサービスを作成しました。 I各スレッドのパラメータで名前でコンポーネントを解決します。Castle Windsorに別のAppDomainにコンポーネントを作成するよう伝えることはできますか?

コンポーネントで使用されているサードパーティライブラリで同時実行性の問題が発生しています。私は別のAppDomainsでこれらのコンポーネントを分離することで問題が解決されると思う。

Resolveに別のAppDomainを使用してコンポーネントを作成させる方法はありますか?

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

は、別のAppDomain *の*で物事をしたいあなたは確かではなく、スレッドごとにコンポーネントインスタンスの、ありますか? (http://www.castleproject.org/container/documentation/trunk/usersguide/lifestyles.htmlのPerThreadを参照してください) –

+0

私はAppDomainsを使用して、潜在的に有害なコンポーネントを互いに分離しようとしています。たとえば、COMオブジェクトをインスタンス化するサードパーティライブラリを使用します。 –

答えて

1

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

関連する問題