I'm working with the cfapi and are attempting to extend the sample project available here https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/CloudMirror
Specifically we are looking to implement the CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS to provide directory content on-demand. Our callbacks are registered like so:-
CF_CALLBACK_REGISTRATION FakeCloudProvider::s_MirrorCallbackTable[] =
{
{ CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS, FakeCloudProvider::OnFetchPlaceholders },
{ CF_CALLBACK_TYPE_FETCH_DATA, FakeCloudProvider::OnFetchData },
{ CF_CALLBACK_TYPE_CANCEL_FETCH_DATA, FakeCloudProvider::OnCancelFetchData },
CF_CALLBACK_REGISTRATION_END
};
The OnFetchPlaceholders method calls CfExecute() to respond to the callback with an array of placeholders for the associated files in the server directory.
CF_OPERATION_INFO opInfo = { 0 };
CF_OPERATION_PARAMETERS opParams = { 0 };
opInfo.StructSize = sizeof(opInfo);
opInfo.Type = CF_OPERATION_TYPE_TRANSFER_PLACEHOLDERS;
opInfo.ConnectionKey = callbackInfo->ConnectionKey;
opInfo.TransferKey = callbackInfo->TransferKey;
opParams.ParamSize = sizeof(opParams);
opParams.TransferPlaceholders.CompletionStatus = status;
opParams.TransferPlaceholders.Flags = CF_OPERATION_TRANSFER_PLACEHOLDERS_FLAG_NONE;
opParams.TransferPlaceholders.PlaceholderArray = placeholders;
opParams.TransferPlaceholders.PlaceholderCount = placeholdersCount;
opParams.TransferPlaceholders.PlaceholderTotalCount.QuadPart = placeholdersCount;
winrt::check_hresult(CfExecute(&opInfo, &opParams));
Unexpectedly, with just three files in the server directory and no subdirectories the OnFetchPlacehodlers function is called many times in quick succession (457 times in the test I just carried out) - to the extent where Explorer stops responding for a while. Strangely the number of times that the method is called seems to vary between about 200 and 500 but there doesn't seem to be any discernible pattern.
I've tried setting the flag CF_OPERATION_TRANSFER_PLACEHOLDERS_FLAG_DISABLE_ON_DEMAND_POPULATION in the callback and when I do this we are only called once but once set we are never asked again for the placeholders even if we have new ones to provide.