LifetimeContext.GetOrCreate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves a shared part instance with the specified ID, or if the part instance can not be found, creates and shares a part instance using the specified creator within the specified operation.
public:
System::Object ^ GetOrCreate(int sharingId, System::Composition::Hosting::Core::CompositionOperation ^ operation, System::Composition::Hosting::Core::CompositeActivator ^ creator);
public object GetOrCreate (int sharingId, System.Composition.Hosting.Core.CompositionOperation operation, System.Composition.Hosting.Core.CompositeActivator creator);
member this.GetOrCreate : int * System.Composition.Hosting.Core.CompositionOperation * System.Composition.Hosting.Core.CompositeActivator -> obj
Public Function GetOrCreate (sharingId As Integer, operation As CompositionOperation, creator As CompositeActivator) As Object
Parameters
- sharingId
- Int32
The ID of the shared part.
- operation
- CompositionOperation
An operation in which to create a part, if necessary.
- creator
- CompositeActivator
An activator that can activate a new part instance, if necessary.
Returns
The new or retrieved part.
Remarks
This method is lock-free if the part instance already exists. If the part instance must be created, a lock will be taken that will serialize other writes that use this method (concurrent reads will continue to be safe and lock-free). It is important that the composition, and thus lock acquisition, is strictly leaf-to-root in the lifetime tree.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기