ICLRTask::Reset Method
Informs the common language runtime (CLR) that the host has completed a task, and enables the CLR to reuse the current ICLRTask instance to represent another task.
HRESULT Reset (
[in] BOOL fFull
);
Parameters
fFull
[in] true, if the runtime should reset all thread-related static values in addition to the security and locale information related to the current ICLRTask instance; otherwise, false.If the value is true, the runtime resets data that was stored using AllocateDataSlot or AllocateNamedDataSlot.
Return Value
HRESULT |
Description |
---|---|
S_OK |
Reset returned successfully. |
HOST_E_CLRNOTAVAILABLE |
The CLR has not been loaded into a process, or the CLR is in a state in which it cannot run managed code or process the call. successfully |
HOST_E_TIMEOUT |
The call timed out. |
HOST_E_NOT_OWNER |
The caller does not own the lock. |
HOST_E_ABANDONED |
An event was canceled while a blocked thread or fiber was waiting on it. |
E_FAIL |
An unknown catastrophic failure occurred. When a method returns E_FAIL, the CLR is no longer usable within the process. Subsequent calls to hosting methods return HOST_E_CLRNOTAVAILABLE. |
Remarks
The CLR can recycle previously created ICLRTask instances to avoid the overhead of repeatedly creating new instances every time it needs a fresh task. The host enables this feature by calling ICLRTask::Reset instead of ICLRTask::ExitTask when it has completed a task. The following list summarizes the normal life cycle of an ICLRTask instance:
The runtime creates a new ICLRTask instance.
The runtime calls IHostTaskManager::GetCurrentTask to get a reference to the current host task.
The runtime calls IHostTask::SetCLRTask to associate the new instance with the host task.
The task executes and completes.
The host destroys the task by calling ICLRTask::ExitTask.
Reset alters this scenario in two ways. In step 5 above, the host calls Reset to reset the task to a clean state, and then decouples the ICLRTask instance from its associated IHostTask instance. If desired, the host can also cache the IHostTask instance for reuse. In step 1 above, the runtime pulls a recycled ICLRTask from the cache instead of creating a new instance.
This approach works well when the host also has a pool of reusable worker tasks. When the host destroys one of its IHostTask instances, it destroys the corresponding ICLRTask by calling ExitTask.
Requirements
Platforms: Windows 2000, Windows XP, Windows Server 2003 family
Header: MSCorEE.idl
Library: Included as a resource in MSCorEE.dll
.NET Framework Version: 2.0