Long running operations

Overview

Long running tasks are also called background tasks or, by their .NET implementation on the server, Scheduled tasks. Their logic runs on a separate thread, or threads, on the server and it usually take a long time to execute. One example of a long-running background task is the regeneration of an image library’s thumbnails.

Regenerate thumbnails

This operation applies to albums only. It triggering the regenerate thumbnails scheduled task.

To regenerate the thumbnails of albums, execute a GET request to the following endpoint:

{baseurl}/api/default/Default.ManageBackgroundTasks

Sample request

GET http://mysite.com/api/default/Default.ManageBackgroundTasks

Request body
JSON
{
    "action": "",
    "itemId": "80c3b126-cd64-4044-abc3-227043c8be20",
    "taskType": "RegenerateThumbnails"
}

Sample response

Status code: 200 OK
JSON
{
    "@odata.context": "http://mysite.com/api/default/$metadata#Collection(Telerik.Sitefinity.Scheduling.Web.Services.WcfScheduledTask)",
    "value": [
        {
            "Id": "0839c6a7-54a4-45d9-8a61-52ecd836c13e",
            "Description": "Regenerating thumbnails",
            "TaskName": "Telerik.Sitefinity.Modules.Libraries.LibraryThumbnailsRegenerateTask",
            "Status": "Pending",
            "StatusMessage": null,
            "ProgressStatus": 0,
            "TaskData": "80c3b126-cd64-4044-abc3-227043c8be20;OpenAccessDataProvider;;d28f6782-349f-49e1-ac44-0fef44c48931",
            "ConcurrentTaskKey": "80c3b126-cd64-4044-abc3-227043c8be20",
            "Title": "Animals Library",
            "IsManageable": true
        }
    ]
}

Change parent library

This operation applies to images, videos, and documents.

The operation of moving items to another library applies to libraries, folders, and media items. This way, you can move folders and media items with one request. This triggers a background task.

NOTE: You cannot move a library to the root. You can only move a library to an already existing root library or child folder. If a root library is moved into another root library the first root library will be converted into a folder and will inherit all properties, such a maximum library size from its new parent library.

To change the parent of a library, execute a POST request to the following endpoint:

{baseUrl}/api/default/{entity}/Default.Move()

Where{entity} is the entity of the module that you are working with. It is one of albums, videolibraries, or documentlibraries.

Sample request

POST http://mysite.com/api/default/images/Default.Move()

Request body
JSON
{
    "items": ["084ff0fa-2a4c-4be9-827b-69ef34c0a95c", "dd66dab3-c7e7-4753-931e-7ff47046fa6f", "43d06f6a-513f-4014-a707-f2da1b10844f"],
    "target": "80c3b126-cd64-4044-abc3-227043c8be20"
}

Sample response

Status code: 204 No Content

No response body

Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.