`
zdx3578
  • 浏览: 95386 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

webistrano 3 task 代码

 
阅读更多

:agit_up_tag_nocheck,   ........................................ 不检查
:agit_up_tag_parallel_Maxall_nocheck_rollback ....... 多服务器并行(不是一台一台串行执行)  主要想回滚时快速
:agit_up_tag,
:a_git_up_tag_OR_restart,  .................................... 部署和重启都有的task (tag 为  re  则  重启)
:agit_up_tag_cmdb,.
:gitinit_gettag,   .................................................... 更新tag 已经合并到了 部署task里面
:z_gitinit_gettag_nocheck, ..................................... 更新tag但是不检查
:all_ReStart_java_sc_iis,   ......................................只是重启   (会自动化根据路径重启java或sc 或iis(回收所有应用池))
:z_jbosscmd_gen, .................................................重新生成jboss 脚本
:z_tomcat_nohup,...................................................重新生成tomcat  nohup  脚本
:luxstop_serv,
:luxstart_serv,
:zz_luxrestart_serv,
:luxstatus_serv,
:z_custom_test, ................................................... 自定义脚本运行   
:z_outip,  
:backup_gitpath  ................................................... 备份 
:z_mq, .................................................................. 检查mq
:z_dns, 
:zz_iisrecycle_start_Pool,
:z_check_app_version ........................................... 检查版本
:z_git_reset__hard,
:winstartservice,
:winstopservice,
:zz_winServiceRestart,
:y_sc_old_getconfig, ................................................. 服务迁移获取已有配置 
:y_sc_new_createsc,................................................. 新服务器上创建服务  服务迁移
:z_Git_Ip_Init_Push_ProdToGitServ,   ..........................新应用初始化时将生产内容推送到git server
:z_Git_Ip_InitGetGitDir_fromGitserver,......................... 新应用初始化时将生产已经推送到git server的内容获取到本地并设置git    详细参考下面以前的说明
:z_iisinfo,  ................................................................ 获取iis 信息

 

 

 






        begin
               puts "#{su_user}"
        rescue => error  then
              su_user_real="#{user}";puts "su user is user #{user}"
        else
             su_user_real="#{su_user}";puts "su user is su_user #{su_user}"
        end







def getsccmd(scnames,stoporstart)

        @scstopcmd="";@scstartcmd="";@scquerycmd="";@stoptime="";@starttime="";@scquerycmdstart=""

        scnames.each do |scname|
                @scstopcmd=@scstopcmd+ " echo #{scname} ; sc stop   #{scname} |grep STATE; "
                @scstartcmd=@scstartcmd+" echo #{scname} ; sc start  #{scname} |grep STATE; "


                scok="if [[ `sc query #{scname}|grep STATE|awk \'{print $4}\'` = STOPPED ]] ;then scok=failedstoped;fi;"
                @scquerycmd=@scquerycmd  +        " echo #{scname} ; sc query  #{scname} |grep STATE;  sc qc #{scname} |grep START_TYPE ; "
                @scquerycmdstart=@scquerycmdstart+" echo #{scname} ; sc query  #{scname} |grep STATE;  sc qc #{scname} |grep START_TYPE ; " +scok


                @stoptime =@stoptime + "while [[ `sc query #{scname}|grep STATE|awk \'{print $4}\'` = STOP_PENDING ]] ;do ping 127.0.0.1 -n 4  >> /dev/null &&  echo stoping  ;done;"
                @starttime =@starttime + "while [[ `sc query #{scname}|grep STATE|awk \'{print $4}\'` = START_PENDING ]] ;do ping 127.0.0.1 -n 4 >> /dev/null && echo starting ;done;"
        end


        detectsc="if [[ $scok == failedstoped ]];then echo -------- sc FAILED!!!!!!!!!!!NO!NO!!!!!!!!!!!!!!!!!!--maybe sc forbid so not start ;else echo -------- sc startok! ---------;fi;"

        @scstopall=@scstopcmd+@stoptime+@scquerycmd
        @scstartall=@scstartcmd+@starttime+@scquerycmdstart+detectsc


        if stoporstart == "start"
        then
                return @scstartall
        else
                return @scstopall
        end
end




begin
       puts "#{servicename}"
rescue => error  then
      @scstop="echo there no win service;";
      @scstart="echo there no win service;";
else
        scnames=servicename.split
        @scstop=getsccmd(scnames,"stop")
        @scstart=getsccmd(scnames,"start")
end







@iisstartpoolcmd00="cscript.exe \"c:\\Inetpub\\AdminScripts\\adsutil.vbs\"   ENUM /P W3SVC/AppPools|grep W3SVC|cut -d[ -f2|cut -d] -f1|xargs -I {} cscript  \"C:\\Inetpub\\AdminScripts\\adsutil.vbs\"  START_SERVER  {}|grep -v Microsoft;"
@iisrecypoolcmd00="cscript.exe \"c:\\Inetpub\\AdminScripts\\adsutil.vbs\"   ENUM /P W3SVC/AppPools|grep W3SVC|cut -d/ -f 4|cut -d] -f 1|xargs -I {}  cscript //Nologo \"C:\\windows\\system32\\iisapp.vbs\"  /a  {} /r;"
@recyclepool=@iisrecypoolcmd00+@iisstartpoolcmd00+@iisrecypoolcmd00+@iisstartpoolcmd00






        begin
               puts "#{appserver_cmd}"
        rescue => error  then
              @appserverrealcmdrestart="echo there no appserver_cmd;";
                @appserverrealcmdstop="echo there no appserver_cmd;";
        else
                appserverrealcmdstart="su - #{su_user_real}  -c  \"#{appserver_cmd}    start\";echo;echo -;"
                @appserverrealcmdstop="su - #{su_user_real}  -c  \"#{appserver_cmd}    stop\";echo -;"
                appserverrealcmdstatus="su - #{su_user_real}  -c  \"#{appserver_cmd}    status\";"
                @appserverrealcmdrestart=@appserverrealcmdstop + appserverrealcmdstart + appserverrealcmdstatus
        end



begin
       puts "#{git_repopath}"
rescue => error  then
      @git_repopath2="echo no   git_repopath    var;exit 1;    ";
else
        @git_repopath2="   git remote add origin git://#{git_server}#{git_repopath} ;"
end









def getgitcmd(git_path,tag_name)
        @ifneedbak="if [[  `git status|wc -l` = 2 ]];then echo -----noUntrackedFile nobak;else echo -----have UntrackedFile baking &&tar -czf  #{git_path}.`date +%Y.%m.%d-%H.%M.%S`.tgz #{git_path}&&ls --full-time -sh #{git_path}.`date +%Y.%m.%d`*;fi;"
        gitstatDirls="ls -a;git status;echo ------------------------------;"
        git_cmd0="git clean -f -d;git reset --hard;git fetch ;git fetch -t ;git reset --merge #{tag_name};"
        ifappdir="if (( `ls -la|wc -l` < 5  ));then echo -----no app dir-----&&echo&&echo&&ls -la&&echo&&echo&&exit 7;else echo appdir ok; fi;"
        gitdircheck=" if [[ -d #{git_path}  ]];then echo git_path ok;else         if [ ! -d #{git_path} ]; then mkdir -p #{git_path} && ls -lhrt #{git_path}; fi; if [ ! -d #{git_path}/.git ]; then cd #{git_path} && pwd && ls -a && git init ;  #{@git_repopath2}    git remote -v && ls -a && git status; fi;          fi; cd #{git_path};"
        git_cmd1= gitdircheck + " beforels=`ls -la |wc -l`; #{@ifneedbak}  #{gitstatDirls}  #{git_cmd0} #{gitstatDirls}  #{git_cmd0} #{gitstatDirls}  afterls=`ls -la |wc -l`;" + ifappdir
        return git_cmd1
end





def git_up_tagcmd()
            _git_cmd=getgitcmd(git_path,tag_name)
        if webistrano_project !~ /allpreverificationconfirm/  && tag_name =~ /pre_/i
            then capcmd="echo !!pre tag should not to production!!;exit 4;"
        else
            if webistrano_stage =~ /gbk/i then
                gitcmd="pwd;export LANG=zh_CN.GBK;#{_git_cmd}"
            else
                gitcmd= _git_cmd
            end
            if git_path !~ /\/cygdrive\// then
                capcmd=gitcmd + @appserverrealcmdrestart
            else
                   if git_path =~ /website/i  then
                       capcmd=" #{gitcmd}   #{@recyclepool}"
                   else
                       capcmd="#{@scstop}  #{gitcmd}  #{@scstart}"
                   end
            end
        end
        return  capcmd
end




def checktagcmd(git_path)
        echocmd="cd #{git_path};  echo;echo;echo;echo;"
        gettagcmdis="nowtagsha=`git reset --hard|awk \'{print $5}\'`;nowtag=`git show-ref|grep $nowtagsha|grep tags|awk -F/ \'{print $3}\' `;"
        contraststatis="echo -  To-  tag is ------: #{tag_name};echo - now tag is ------: $nowtag; echo `date` ; echo update before ls -a line : $beforels;echo update after-  ls -a line : $afterls ; "
        detectsuccessorfailed="if  [[ #{tag_name} = $nowtag ]];then echo deploy ok!!! ; else echo --!!!tag ERROR!look for yuzhifu wangdawei!!&&echo&&echo&&exit 5;fi;"
        detectsc="if [[ $scok == failedstoped ]];then echo -------- sc failed!! ---------maybe sc forbid so no exit;else echo -------- sc startok! ---------;fi;"
        checktagcmdreturn= echocmd +   gettagcmdis  + contraststatis  +        echocmd +    detectsuccessorfailed + detectsc  + echocmd
        return checktagcmdreturn
end





        begin
               puts "#{checkurl}"
        rescue => error  then
              checkurlcmd="echo no checkurl var define"
        else
              checkurlcmd="httpline=`curl -s --head #{checkurl} | grep HTTP`;echo $httpline;retcode=`echo $httpline|awk \'{print $2}\'`;if [[ $retcode == 200 || $retcode == 302 ]];then echo&&echo !!application initial sucess;else #{@appserverrealcmdstop} #{@scstop} echo&&echo !!application ERROR&&echo result is $httpline&&echo&&exit 1;fi;"
        end




    task :agit_up_tag_nocheck, :max_hosts=>1 do
        run git_up_tagcmd()
    end


    task :agit_up_tag_parallel_Maxall_nocheck_rollback   do
        run git_up_tagcmd()
    end


    task :agit_up_tag, :max_hosts=>1 do
        run   git_up_tagcmd() + checktagcmd(git_path) + checkurlcmd
    end


    task :a_git_up_tag_OR_restart, :max_hosts=>1 do
        if tag_name != "re"
        then  agit_up_tag
        else  all_ReStart_java_sc_iis
        end
    end


    desc "cmdb git up tag"
    task :agit_up_tag_cmdb, :roles => :single do
      version = tag_name
      svrs = find_servers :roles => :app
      servers = svrs.join(",")
      deploy_unit_code = ""
      if version =~ /(zf\d+)/
        deploy_unit_code = $1
      end
      deploy_to = git_path
      puts "version=#{version}, servers=#{servers}, deploy_dir=#{deploy_to}"

      CmdbService.do_deploy_with_server(cse_base, deploy_unit_code, deploy_stage, version.strip, servers, deploy_to) do
        agit_up_tag
      end
    end



  desc "default cmds : linux init git and git-tag"
    task :z_gitinit_gettag_nocheck, :max_hosts=>1 do
         _git_cmd=getgitcmd(git_path,tag_name)
        run "if [ ! -d #{git_path} ]; then mkdir -p #{git_path} && ls -lhrt #{git_path}; fi"
        run "if [ ! -d #{git_path}/.git ]; then cd #{git_path} && pwd && ls -a && git init && git remote add origin git://#{git_server}#{git_repopath} &&  git remote -v && ls -a && git status; fi"
        run %{
            #{_git_cmd}
         }
   end


@mq="ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 2; ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 2;  ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 2;     ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 2;  ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 2;  ruby   /cygdrive/c/tools/NSClient++/scripts/msmq.rb|unix2dos;echo ;sleep 0.2; "



    task :all_ReStart_java_sc_iis, :max_hosts=>1 do
            if git_path !~ /\/cygdrive\// then
                reScmd= @appserverrealcmdrestart
            else
                   if git_path =~ /website/i  then
                       reScmd="  #{@recyclepool}"
                   else 
                        reScmd0="#{@scstop}    #{@scstart}  "
                        if webistrano_stage =~ /zf255/
                        then reScmd=reScmd0 + @mq
                        else
                               reScmd=reScmd0
                        end
                   end
            end
        run reScmd
    end





    desc "from appserver_cmd gen jbossrestartcmd"
    task :z_jbosscmd_gen, :max_hosts=>1 do
        if appserver_cmd =~ /^sh/
        then cmddir=appserver_cmd.split[1].split("jbossctl-old2.sh")[0];
        else cmddir=appserver_cmd.split[0].split("jbossctl-old2.sh")[0];
        end
        puts cmddir
        jbossgencmd="cp /home/jbossoldshgen.sh   #{cmddir}   ;cd     #{cmddir}    ;  sh jbossoldshgen.sh gen;  echo ok!;pwd;ls;"
        run %{
            #{jbossgencmd}
        }
    end
  


    task :z_tomcat_nohup, :max_hosts=>1 do
        if appserver_cmd =~ /^sh/
        then cmdpath=appserver_cmd.split[1];
        else cmdpath=appserver_cmd.split[0];
        end
        puts cmdpath
        date=`date +%Y%m%d%H%M%S `
        run %{
echo;
if ((`grep -E  "nohup .*SCRIPT_TO_RUN.* start"  #{cmdpath} | wc -l ` == 0 ))   ; then    sed -i.bak.#{date}  -f /home/tomcatsedfile  #{cmdpath} ; diff #{cmdpath} #{cmdpath}.bak.#{date}; else echo  #{cmdpath} ; grep -n -E  "nohup .*SCRIPT_TO_RUN.* start"  #{cmdpath}; fi;
echo;
        }
    end




    desc "stop server or service"
    task :luxstop_serv, :max_hosts=>1 do
        run %{
            su - #{su_user_real}  -c  "#{appserver_cmd}  stop" ;  
            su - #{su_user_real}  -c  "#{appserver_cmd}  status";  
        }       
    end

    desc "start server or service"
    task :luxstart_serv, :max_hosts=>1 do
        run %{
           su - #{su_user_real}  -c  "#{appserver_cmd}  start"   ;   
           su - #{su_user_real}  -c  "#{appserver_cmd}  status";  
        }        
    end

    desc "restart server or service"
    task :zz_luxrestart_serv, :max_hosts=>1 do
        run %{
            su - #{su_user_real}  -c  "#{appserver_cmd}  restart" ;
            su - #{su_user_real}  -c  "#{appserver_cmd}  status";  
        }        
    end

    desc "status server or service"
    task :luxstatus_serv, :max_hosts=>1 do
        run %{
            su - #{su_user_real}  -c  "#{appserver_cmd}  status;ps -efjH|grep java|grep -v grep;"     
        }
    end

    desc "custom test cmd"
    task :z_custom_test, :max_hosts=>1 do
        run %{
            #{custom_test_cmd}
        }
    end

    task :z_outip, :max_hosts=>1 do
        run %{
             curl http://uam.corp......com/Service/getip.aspx
        }
    end


    desc "backup git path "
    task :backup_gitpath  do
        run %{
             tar -czf  #{git_path}.`date +%Y.%m.%d-%H.%M.%S`.tgz  #{git_path};
             ls  --full-time  -sh    #{git_path}.`date +%Y.%m.%d`*
        }
    end



    task :z_mq, :max_hosts=>1 do
        run @mq
    end


    task :z_dns, :max_hosts=>1  do
        run %{ echo;  if [[ -f /etc/issue ]]; then ping -c 1  #{tag_name}   ;cat /etc/resolv.conf  ; else ping -n 1 #{tag_name}  ;ipconfig /all|grep  "DNS Servers" -A4 ;fi; echo;
        }
     end


    desc "recycle start ApplicationPool"
    task :zz_iisrecycle_start_Pool, :max_hosts=>1  do
        run %{
            #{@recyclepool}
        }
    end


    task :z_addGzipLogCron, :max_hosts=>1 do
        run %{
mkdir  -p  /opt/importdir/crontabdir/;
echo 'gzip -rv  /logs/*/*`date --date="1 day ago" +%F`* ' >>  /opt/importdir/crontabdir/crontablog.sh;
echo '10 13 * * * bash /opt/importdir/crontabdir/crontablog.sh  ' >>   /var/spool/cron/root;
crontab -l ;cat /opt/importdir/crontabdir/crontablog.sh;echo ???????????? alert log location ?????????????  ;
            }
    end


    task :z_check_app_version  do
        run %{
            cd #{git_path};   git log --pretty=oneline -1|unix2dos;
         }
    end

    task :z_git_reset__hard, :max_hosts=>1  do
        run %{
            cd #{git_path};#{@ifneedbak}  git status;   git reset --hard ;
         }
    end






    desc "service start"
    task :winstartservice, :max_hosts=>1 do
        run %{
            #{@scstart}
         }
    end

    desc "service stop"
    task :winstopservice, :max_hosts=>1 do
        run %{
            #{@scstop}
        }
    end



    desc "service query"
    task :winserviceStatus, :max_hosts=>1 do
        run %{
             #{@scquerycmd}
        }
    end



    desc "service restart"
    task :zz_winServiceRestart, :max_hosts=>1 do
         run %{
                #{@scstop}
                #{@scstart}       }
    end







    task :y_sc_old_getconfig, :max_hosts=>1  do
        run %{ 
            cd /tmp/;   pwd;
            git clone    gituser@#{git_server}:/opt/gitzf332-382/zfsor1001migrate.git;
            cd zfsor1001migrate; git pull ;   pwd;        mkdir  #{webistrano_stage};      
            sc qc  #{servicename}|grep BINARY_PATH_NAME|awk '{print $3}'    >> #{webistrano_stage}/scconfig;
            echo -----  cat begin all config in file; cat  #{webistrano_stage}/scconfig;echo -----  cat end;
            git status;            git add . ;          git commit -am " auto `date +%Y.%m.%d-%H.%M.%S`  `pwd` #{webistrano_stage}  sc path ";
            git push  origin master;
            }
     end


    task :y_sc_new_createsc, :max_hosts=>1  do
            z_gitinit_gettag_nocheck
        run %{ 
            cd /tmp/;   pwd;
            git clone    git://#{git_server}/opt/gitzf332-382/zfsor1001migrate.git;echo;
            cd zfsor1001migrate;   git pull;  echo;   cd  #{webistrano_stage};       pwd;echo -----  cat begin;
            cat  scconfig;echo -----  cat end;echo;echo;echo;
            echo   sc create #{servicename} binpath= `tail -n 1 ./scconfig` start= disabled;echo;echo ----------before create;echo;
            sc create #{servicename} binpath= `tail -n 1 ./scconfig` start= disabled;
            echo;echo;echo;echo;echo --------------after create sc query;echo;
            sc query  #{servicename}  ;echo;  echo sc qc query; echo;echo;echo ;
            sc qc #{servicename} ;echo; echo exefinal;
        }
    end




     desc "push product to git server"
     task :z_Git_Init_Push_ProdToGitServ, :max_hosts=>1 do
         run %{
                if [[ -d #{git_path}  ]];then echo git_path ok;else echo no git_path.dir&&echo&&echo&&exit 8;fi;
               cd #{git_path};
               pwd;ls -a;
               git init;
               git add . ;
               git commit -am "product webistrano auto `date +%Y.%m.%d-%H.%M.%S`   `pwd` " ;
               git remote add origin gituser@#{git_server}:#{git_repopath}  ;
               git remote -v;
                echo ;echo;echo;echo;echo;echo;echo -------------------------push !!!!!!!!!!!!!!!!!!!!-------;
               git push origin master ;echo;echo;echo;
               ls -a;echo;echo;echo;git status;echo;echo;echo;git log -n 5|unix2dos;
         }
     end
 
 
     desc "GITgetgitDir_fromGitserver"
     task :z_Git_InitGetGitDir_fromGitserver, :max_hosts=>1 do
         run %{
               dir=`date +%Y%m%d%H%M%S`;  cd /tmp;pwd;git clone git://#{git_server}#{git_repopath}  $dir;
               cd #{git_path};pwd;ls -a; cp -r /tmp/$dir/.git    ./; ls -a;git status;
         }
     end




    desc "get iis info"
    task :z_iisinfo, :max_hosts=>1 do
         run %{
                       cscript.exe "c:\\Inetpub\\AdminScripts\\adsutil.vbs"   ENUM /P W3SVC/AppPools;
                       cscript //Nologo "C:\\windows\\system32\\iisweb.vbs" /query |awk -F")" '{print $1}'|awk -F"(" '{print $2}'|grep W3SVC|grep -vE "W3SVC/1$" |xargs  -I {} cscript.exe "c:\\Inetpub\\AdminScripts\\adsutil.vbs"  ENUM_ALL {}|grep -E "AppPoolId|Path|Comment"
         }
    end

  end

 

分享到:
评论

相关推荐

    C# Task任务操作代码

    Task类是.NET Framework 4.0引入的,作为System.Threading.Tasks命名空间的一部分,它为编写多线程和并发代码提供了更高级别的抽象。在本篇文章中,我们将深入探讨C#中的Task任务操作及其在动态设定时间执行任务事件...

    springMVC定时任务task方式实例代码

    3. **配置Task执行** 在Spring的配置文件中,需要开启定时任务支持并定义`TaskScheduler`实现类,例如使用`ThreadPoolTaskScheduler`: ```xml &lt;bean id="taskScheduler" class="org.springframework.scheduling....

    Hadoop源代码分析(MapTask)

    Hadoop源代码分析(MapTask) Hadoop的MapTask类是Hadoop MapReduce框架中的一部分,负责执行Map任务。MapTask类继承自Task类,是MapReduce框架中的一个重要组件。本文将对MapTask类的源代码进行分析,了解其内部...

    task1.1代码测试

    task1.1代码测试

    Task1代码详细分析

    Task1代码详细分析

    独立任务Independent Task Scheduling

    Independent Task Scheduling

    task2baseline代码

    task2baseline代码

    go-task task计划任务

    ### 3. URL访问 任务类型初期只支持访问URL,这通常用于监控Web服务的可用性或性能。通过发起HTTP请求,检查响应状态码和返回内容,可以判断服务是否正常运行。Go语言的`net/http`包提供了方便的API用于发起GET、...

    2019年浙江省机器人竞赛足球4V4对抗赛skill和task部分开源代码-robot-soccer-4V4.zip

    2019年浙江省机器人竞赛足球4V4对抗赛skill和task部分开源代码_robot_soccer_4V4.zip 2019年浙江省机器人竞赛足球4V4对抗赛skill和task部分开源代码_robot_soccer_4V4.zip 2019年浙江省机器人竞赛足球4V4对抗赛skill...

    工作流中ServiceTask的各种方法

    3. 调用Spring Bean中的方法 ServiceTask也可以通过activiti:expression属性来调用Spring Bean中的方法。在下面的示例代码中,我们将调用sentenceGenerator.getSentence()方法: ```xml &lt;serviceTask id="service...

    Android代码-Termux:Task

    Released under the GPLv3 license. How to use Create a new Tasker Action. In the resulting Select Action Category dialog, select Plugin. In the resulting Termux:Task dialog, select Termux:Task. Edit ...

    ucos task源代码

    ucos 中的task源代码 给想看的朋友们

    EasyTask简单易用的PHP常驻内存多进程任务管理器.zip

    3. 示例项目:展示了如何定义任务和使用EasyTask进行多进程管理。 4. Windows组件:可能包含Windows下的服务安装脚本或守护进程,使得EasyTask能在Windows系统上持续运行。 通过学习和应用EasyTask,开发者可以构建...

    C#中的Task介绍

    3. **调度策略**:Thread由系统调度,而Task由TPL根据系统资源和任务优先级进行智能调度,能更好地平衡负载。 4. **错误处理**:Task可以捕获并封装异常,而Thread中异常会导致整个线程终止。 5. **取消机制**:Task...

    自定义AntTask简单实例

    自定义Ant Task的优势在于它可以将任何Java代码集成到构建流程中,实现如代码分析、特殊格式化或特定的部署逻辑等功能。同时,由于Task的定义是XML化的,它保持了Ant脚本的可读性和可维护性。 总结一下,自定义Ant ...

    大量Task创建导致UI失去响应

    代码里面用新线程执行大量的task创建,发现在创建的时候导致UI失去响应,等task创建完毕,运行的时候,UI正常。 for (int i = 0; i ; i++) { //Func, string&gt; taskfunc = test; //为什么会造成UI假死? Task...

    博客《C# 取消Task几个注意事项》的代码实例

    创建Task的时不想带入参数token,又想在外部终结掉当前Task,就没有办法了吗?答案是:No 我们还有一招,就是在Task内部的循环体内植入异常抛出,如:

    c# Task 多线程管理 v1

    3. **并发控制**:`Task`提供了多种并发控制机制,如`TaskCreationOptions`枚举,可以设置为`PreferFairness`以实现公平的线程调度,或者`LongRunning`来表示长时间运行的任务,这样它们不会被放入线程池而是创建新...

    NLPCC2014task1和task2数据集资源.zip

    NLPCC2014task1和task2数据集资源NLPCC2014task1和task2数据集资源NLPCC2014task1和task2数据集资源NLPCC2014task1和task2数据集资源NLPCC2014task1和task2数据集资源NLPCC2014task1和task2数据集资源NLPCC2014task1...

Global site tag (gtag.js) - Google Analytics