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