Поделиться через


Метод Sys.Net.WebRequestExecutor abort

Останавливает ожидающий сетевой запрос, сделанный выполнителем.

MyExecutor.abort();

Заметки

Особенности прерывания запроса зависят от реализации выполнителя. Однако, все выполнители, наследуемые от WebRequestExecutor, должны установить свое состояние в прерванное и вызвать событие завершения для связанного объекта Sys.Net.WebRequest.

Примечание

После вызова метода abort данные в свойствах выполнителя оказываются не согласованными

Пример

В следующем примере демонстрируется прерывание запроса с помощью класса Sys.Net.XMLHttpExecutor по умолчанию.

// This function aborts a Web request.
function AbortWebRequest()
{
    // Create the WebRequest object.
    wRequest =  new Sys.Net.WebRequest();

    // Set the request Url.  
    wRequest.set_url("getTarget.htm");

   // Clear the results area.
    resultElementId.innerHTML = "";

    // Set the Completed event handler, 
    // for processing return data
    wRequest.add_completed(OnCompleted);

    // Make the request.
    wRequest.invoke();

    // Get the current executor.
    var executor = wRequest.get_executor();


    // Abort the request.
    executor.abort();

    // Check if the executor is aborted.
    var execAborted = 
        executor.get_aborted();

    alert("Executor aborted: " + execAborted);
}

См. также

Ссылки

Класс Sys.Net.WebRequestManager

Класс Sys.Net.WebRequest

Класс Sys.Net.XMLHttpExecutor