Codesmith Use Tutorial (9): Progress Object __codesmith

Source: Internet
Author: User


Using the Progress object can display a progress bar for the process of generating code for Codesmith, which is useful for generating more time-consuming template operations, and if you use visual Studio, you can display a progress bar in the Status column:

The way to use the progress bar is to codetemplate the object's Progress Property object, first by setting the maximum value and step size of the progress object, and this example simulates a time-consuming operation by a simple loop:

[CSharp] View Plain copy print? <%@ template language= "C #"  targetlanguage= "Text"  debug= "False"  %>      <%@ import namespace= "System.Threading"  %>   this is a  progress demo.      <% simulateprogress (); %>       <script runat= "template" >   public void simulateprogress () {      progress.maximumvalue = 25;   progress.step = 1;           for (int i=0;i<25;i++) {            progress.performstep ();           thread.sleep ( ;           response.writeline ("step {0} ", I);        }  }   </script>  

<%@ Template language= "C #" targetlanguage= "Text" debug= "False"%>

<%@ Import namespace= "System.Threading "%> This is
a progress demo.

<% simulateprogress (); %>

<script runat= "template" > Public
void Simulateprogress () {

progress.maximumvalue =;
Progress.step = 1;

    for (int i=0;i<25;i++) {
        progress.performstep ();
        Thread.Sleep (m);
        Response.writeline ("Step {0}", i);
    }
</script>

The progress bar is further implemented by the Perfstep method of the Progress object.

This example downloads

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.