Udostępnij za pośrednictwem


IBuildEngine4.RegisterTaskObject Method

Definition

Registers an object with the system that will be disposed of at some specified time in the future.

public:
 void RegisterTaskObject(System::Object ^ key, System::Object ^ obj, Microsoft::Build::Framework::RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection);
public void RegisterTaskObject (object key, object obj, Microsoft.Build.Framework.RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection);
abstract member RegisterTaskObject : obj * obj * Microsoft.Build.Framework.RegisteredTaskObjectLifetime * bool -> unit
Public Sub RegisterTaskObject (key As Object, obj As Object, lifetime As RegisteredTaskObjectLifetime, allowEarlyCollection As Boolean)

Parameters

key
Object

The key used to retrieve the object.

obj
Object

The object to be held for later disposal.

lifetime
RegisteredTaskObjectLifetime

The lifetime of the object.

allowEarlyCollection
Boolean

The object may be disposed earlier that the requested time if MSBuild needs to reclaim memory.

Remarks

This method may be called by tasks which need to maintain state across task invocations, such as to cache data which may be expensive to generate but which is known not to change during the build. It is strongly recommended that allowEarlyCollection be set to true if the object will retain any significant amount of data, as this gives MSBuild the most flexibility to manage limited process memory resources.

The thread on which the object is disposed may be arbitrary - however it is guaranteed not to be disposed while the task is executing, even if allowEarlyCollection is set to true.

If the object implements IDisposable, IDisposable.Dispose will be invoked on the object before discarding it.

Applies to