description | title | ms.date | api_name | api_location | api_type | f1_keywords | helpviewer_keywords | ms.assetid | topic_type | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: ICLRTask::Reset Method |
ICLRTask::Reset Method |
03/30/2017 |
|
|
|
|
|
1bfb5d3a-0ffd-4bb4-9bf6-aec00cb675b7 |
|
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
);
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 xref:System.Threading.Thread.AllocateDataSlot%2A or xref:System.Threading.Thread.AllocateNamedDataSlot%2A.
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. |
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
.
Platforms: See System Requirements.
Header: MSCorEE.h
Library: Included as a resource in MSCorEE.dll
.NET Framework Versions: [!INCLUDEnet_current_v20plus]