home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / scheduler.aspx < prev    next >
Encoding:
Text File  |  2000-06-07  |  3.9 KB  |  88 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <%
  5.     runsample = Server.MapPath("/quickstart/howto/samples/Services/Timers/Scheduler")
  6.     viewsource = "/quickstart/howto/samples/Services/Timers/Scheduler/Scheduler.src"
  7.     icon = "/quickstart/images/genicon.gif"
  8.     caption = "Scheduler.exe"
  9. %>
  10.  
  11. <h4>How Do I...Execute custom code at specified times?</h4>
  12.  
  13. <div class="indent" style="width:660">
  14. <font face="Tahoma" size="1">
  15. You can create a Schedule component instance for your processing that raises an event on a daily, weekly, monthly, or other calendar-based schedule. 
  16. You can use this component to automate your business processing. 
  17. For example, you might create a Schedule component to automatically raise events on the last Friday of every month. 
  18. Other classes or components in your application might handle the events this component raises, for example, running logic that 
  19. tabulates tax information for the month, computes monthly sales, and generates a monthly payroll report.<br>
  20. <br>
  21. This sample illustrates how to create a Schedule that uses the RecurrencePatternsDialog to define the pattern of when to raise events.
  22. Run the sample as follows:<br>
  23. <br>
  24.     </font><font face="Courier New" size="2" color="#0000FF">>
  25. Scheduler.exe c:\winnt\notepad.exe</font>
  26. <p><font face="Tahoma" size="1">
  27. Now, specify the schedule for opening Notepad and click OK. the specified process
  28. (Notepad) will start according to the pattern specified in the
  29. RecurrencePatternsDialog.<br>
  30. <br>
  31. In its simplest form, creating a Schedule that uses the RecurrencePatternsDialog involves:<br>
  32. <br>
  33. 1. Creating a new instance of Schedule:<br>
  34. <br>
  35. </font><font face="Courier New" size="2" color="#0000FF">    Schedule
  36. aSchedule = new Schedule();</font><font face="Tahoma" size="1"><br>
  37. <br>
  38. 2. Creating a new instance of RecurrencePatternsDialog:<br>
  39. <br>
  40. </font><font face="Courier New" size="2" color="#0000FF">   
  41. RecurrencePatternsDialog dlg = new RecurrencePatternsDialog();<br>
  42.     dlg.RecurrencePatterns = aSchedule.RecurrencePatterns;<br>
  43.     dlg.ShowDialog();</font><font face="Tahoma" size="1"><br>
  44. <br>
  45. 3. Setting the patterns specified through the dialog into the Schedule:<br>
  46. <br>
  47. </font><font face="Courier New" size="2" color="#0000FF">   
  48. aSchedule.RecurrencePatterns.All = dlg.RecurrencePatterns.All;</font><font face="Tahoma" size="1"><br>
  49. <br>
  50. 4. Specifying the event to raise:<br>
  51. <br>
  52. </font><font face="Courier New" size="2" color="#0000FF">   
  53. aSchedule.AddOnEventOccurred(new OccurredEventHandler(OnScheduledEvent));</font><font face="Tahoma" size="1"><br>
  54. <br>
  55. 5. Enabling the component:<br>
  56. <br>
  57. </font><font face="Courier" size="2" color="#0000FF">   
  58. aSchedule.Enabled = true;</font><font face="Tahoma" size="1"><br>
  59. <br>
  60. 6. Defining the event to raise:<br>
  61. <br>
  62. </font><font face="Courier New" size="2" color="#0000FF">   
  63. public static void OnScheduledEvent(Object source, OccurredEvent e){<br>
  64.         Process.Start(executablePath); <br>
  65.     }</font><br>
  66. </div>
  67.  
  68. <h4>Example</h4>
  69.  
  70. <p>
  71. <div class="indent">
  72. <a target="_blank" href="/quickstart/howto/samples/Services/Timers/Scheduler">
  73. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  74. </a>
  75. <div class="caption">Scheduler.exe</div><br>
  76. [<a target="_blank" href="/quickstart/howto/samples/Services/Timers/Scheduler">View Sample</a>] | 
  77. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/Timers/Scheduler/Scheduler.src">View Source</a>]<p>
  78. </div>
  79.  
  80. <h4>Source Code</h4>
  81.  
  82. <div class="code">
  83. <xmp>
  84. <!-- #include virtual="/quickstart/howto/samples/Services/Timers/Scheduler/Scheduler.cs" -->
  85. </xmp>
  86. </div>
  87.  
  88. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->