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

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <head>
  5. <style>
  6. <!--
  7. code         { font-family: Courier New; font-size: 10pt; color: #0000FF }
  8. -->
  9. </style>
  10. </head>
  11.  
  12. <h4>How Do I...Define complex schedules?</h4>
  13.  
  14. <div class="indent" style="width:660">
  15. <font face="Tahoma" size="1">You can create a Schedule component instance for your 
  16. processing that raises an event on a daily, weekly, monthly, or other calendar-based 
  17. schedule. You can use this component to automate your business processing. For example, 
  18. you might create a Schedule component to automatically raise events on the last Friday 
  19. of every month. Other classes or components in your application might handle the events 
  20. this component raises, for example, running logic that tabulates tax information for the month, 
  21. computes monthly sales, and generates a monthly payroll report.<br>
  22. <br>
  23. This sample illustrates how to create a Schedule that raises an event every week.<br>
  24. <br>
  25. <br>
  26. Now, the message ôHello World!ö will be displayed every 5 seconds each Wednesday between 7:00am and 6:00pm. <br>
  27. <br>
  28. In its simplest form, creating a Schedule involves:<br>
  29. <br>
  30. 1. Creating a new instance of Schedule:<br>
  31. <br>
  32. </font><font face="Courier New" size="2" color="#0000FF">    Schedule aSchedule = new Schedule();</font><font face="Tahoma" size="1"><br>
  33. <br>
  34. 2. Specifying the event to raise:<br>
  35. <br>
  36. </font><font face="Courier New" size="2" color="#0000FF">   
  37. aSchedule.AddOnEventOccurred(new OccurredEventHandler(OnScheduledEvent));</font><font face="Tahoma" size="1"><br>
  38. <br>
  39. 3. Defining the pattern on which to raise the event:<br>
  40. <br>
  41. </font><font face="Courier New" size="2" color="#0000FF">   
  42. WeeklyPattern days = new WeeklyPattern(DaysOfWeek.Wednesday,1);<br>
  43.     days.StartTime = new TimeSpan(7,0,0);<br>
  44.     days.EndTime = new TimeSpan(18,0,0);<br>
  45.     days.Interval = new TimeSpan(0,0,5);<br>
  46.     aSchedule.RecurrencePatterns.Add(days);</font><font face="Tahoma" size="1"><br>
  47. <br>
  48. 4. Enabling the component:<br>
  49. <br>
  50. </font><font face="Courier New" size="2" color="#0000FF">   
  51. aSchedule.Enabled = true;</font><font face="Tahoma" size="1"><br>
  52. <br>
  53. 5. Defining the event to raise:<br>
  54. <br>
  55. </font><font face="Courier New" size="2" color="#0000FF">   
  56. public static void OnScheduledEvent(Object source, OccurredEvent e){<br>
  57.         Console.WriteLine("Hello World!");<br>
  58.     }</font>
  59. </div>
  60.  
  61. <h4>Example</h4>
  62.  
  63. <p>
  64. <div class="indent">
  65. <a target="_blank" href="/quickstart/howto/samples/Services/Timers/ScheduleDemo">
  66. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  67. </a>
  68. <div class="caption">ScheduleDemo.exe</div><br>
  69. [<a target="_blank" href="/quickstart/howto/samples/Services/Timers/ScheduleDemo">View Sample</a>] | 
  70. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/Timers/ScheduleDemo/ScheduleDemo.src">View Source</a>]<p>
  71. </div>
  72.  
  73. <h4>Source Code</h4>
  74.  
  75. <div class="code">
  76. <xmp>
  77. <!-- #include virtual="/quickstart/howto/samples/Services/Timers/ScheduleDemo/ScheduleDemo.cs" -->
  78. </xmp>
  79. </div>
  80.  
  81. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->