CodeSmith tutorial (9): SS object

Source: Internet
Author: User

You can use the Progress object to display a Progress bar during CodeSmith code generation. This is very useful for generating time-consuming template operations. If you use Visual Studio, you can display a Progress bar in the status bar: You can use the Progress bar to set the maximum value and step size of the Progress object through the Progress attribute object of the CodeTemplate object, in this example, a simple loop is used to simulate a time-consuming operation: [csharp] <% @ Template Language = "C #" TargetLanguage = "Text" Debug = "False" %> <% @ Import Namespace = "System. threading "%> This is a progress demo. <% SimulateProgress (); %> <script runat = "template"> public void SimulateProgres S () {Progress. maximumValue = 25; Progress. step = 1; for (int I = 0; I <25; I ++) {Progress. required mstep (); Thread. sleep (100); 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. maximumV Alue = 25; Progress. step = 1; for (int I = 0; I <25; I ++) {Progress. required mstep (); Thread. sleep (100); Response. writeLine ("step {0}", I) ;}</script> the Progress bar is implemented by the PerfStep method of the SS object.

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.