IBuildEngine4.RegisterTaskObject Method (Object, Object, RegisteredTaskObjectLifetime, Boolean)

 

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

MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Namespace:   Microsoft.Build.Framework
Assembly:  Microsoft.Build.Framework (in Microsoft.Build.Framework.dll)

void RegisterTaskObject(
	object key,
	object obj,
	RegisteredTaskObjectLifetime lifetime,
	bool allowEarlyCollection
)

Parameters

key
Type: System.Object

The key used to retrieve the object.

obj
Type: System.Object

The object to be held for later disposal.

lifetime
Type: Microsoft.Build.Framework.RegisteredTaskObjectLifetime

The lifetime of the object.

allowEarlyCollection
Type: System.Boolean

Flag that determines whether the object can be disposed earlier than the requested time.

This method may be called by tasks which need to maintain state across task invocations, such as data caching tasks. It is strongly recommended that allowEarlyCollection be set to true if the object will retain any significant amount of data.

The thread on which the object is disposed may be arbitrarily, but it will not 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.

Return to top
Show: