I'm having a problem, where the Wait for Loading screen in the JavaScript function only appears when I debug, or pauses the script. If I try to execute directly, it does not appear at all.
$('#btnPesquisar').click(function () {
    $.ajax({
        method: 'GET',
        url: '<%= ResolveUrl("LiberarBoleto.aspx/onSearch") %>',
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        data: { pv: JSON.stringify($('#txtVenda').val()), imob: JSON.stringify($('#drpDownImob').val()) },
        success: function (result) {
            console.log('Passo 1')
            showProgress();
            console.log ('Sleep')
            sleep(10000);
            ProcessVendas(result);
            sleep(10000);
            console.log('Passo 2')
            hideProgress();
            console.log('Passo 3')
        }
    });
});
function showProgress() {
    var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
    sleep(10000);
    updateProgress.style.display = "block";
    sleep(10000);
    console.log('Exibição da Tela Aguarde Carregando Concluida')
    //updateProgress.style.display = "none";  
};
function hideProgress() {
    var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
    updateProgress.style.display = "none";
}
function sleep(milliseconds) {
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++) {
        if ((new Date().getTime() - start) > milliseconds) {
            break;
        }
    }
}