zoukankan      html  css  js  c++  java
  • ExtJs 进度条(轮询)

      客户端代码:

          Ext.onReady(function () {
                Ext.get('mb').on('click', function () {
                    Ext.Ajax.request({
                        url: root + "/Test/GetCount",
                        success: function (response) {
                            var sum = response.responseText;
                            Ext.MessageBox.show({
                                title: '删除',
                                msg: '正在删除...',
                                progressText: '',
                                 300,
                                progress: true,
                                closable: false,
                                animateTarget: 'mb'
                            });
                            f(sum);
                        },
                        failure: function () {
                        }
                    });
                });
            });
            function f(v) {
                Ext.Ajax.request({
                    url: root + "/Test/GetCurrentCount",
                    success: function (response) {
                        var curnum = response.responseText;
                        if (curnum == 0) {
                            Ext.MessageBox.hide();
                        }
                        else {
                            var i = (v - curnum) / v;
                            Ext.MessageBox.updateProgress(i, Math.round(100 * i) + '% completed');
                            setTimeout(f(v), 1000);
                        }
                    }
                });
            }

    服务端耗时任务:

     1 public class TestController : Controller
     2     {
     3         private static int _count = 0;
     4         public int GetCount()
     5         {
     6             _count = 10;
     7             ThreadStart ts = new ThreadStart(RunBackThread);
     8             Thread td = new Thread(ts);
     9             td.Start();
    10             return _count;
    11         }
    12         public int GetCurrentCount()
    13         {
    14             return _count;
    15         }
    16         public void RunBackThread()
    17         {
    18             while (_count > 0)
    19             {
    20                 Thread.Sleep(1000);
    21                 _count--;
    22             }
    23         }
    24     }
  • 相关阅读:
    进程池和线程池
    TCP并发、GIL、锁
    进程间通信
    装饰器与反射
    装饰器大全
    面向对象三大特征: 封装 继承 多态
    面向对象 魔术方法
    魔术方法
    ubuntu 中导 tarfile,win 不亲切
    os VS shutil
  • 原文地址:https://www.cnblogs.com/xienb/p/3532913.html
Copyright © 2011-2022 走看看