Home
Username:
Password:
Microsoft Visual Studio .NET Tutorials

Coding the Web Monitor Application / Testing the Web Monitor Application pt. 2




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

The only other thing we need to do is make sure that number of intervals actually contains some value because we want to set count of intervals to it and then we want that value to be incremented. So if we go back up to where we declared number of intervals, we can set it equal to or initialize it equal to 1 and that will take care of that. So it starts out equal to 1 if the server's found to be not running, count of intervals will be set equal to the number of intervals minus 1 which means count of intervals will be set to 0. and then when the tick event is raised, count of intervals would be raised to 1, it will then be equal to the number of intervals and again the processing down here will run. Now all we have to do is set the timer interval and get the timer started. So let's do that, Timer1.Interval equals 6 seconds, we're going to start the timer and that's that. So now if the server is stopped, we set the count of intervals, set the timer interval to 6 seconds, start the timer, 6 seconds later the tick event happens and this code runs. We get the server, we refresh the server status, get the server status and since the server has still stopped, we set the time since value and flash and beep and so forth. So we've got a pretty good start on our coding, We've written quite a few functions and done quite a bit of processing. There is one thing else that we should do, we go back to the design view, we haven't put anything in for the stop button yet, so let's double click that and basically all we're going to do right now is stop the timer so that if we hit the stop button, the timer will stop, no more tick events will take place but we do want to leave the values in place for the notification label for the last access time and the time since that kind of thing, because just because we stopped it doesn't means we want to immediately erase all the data, oh and by the way one more thing on our form, when this group of radio buttons and this group of radio buttons open up on the screen, it would be a good thing to already have a value checked 110 or 60, flash, beep or flash and beep. Reason being if none of these are checked then we would have to put in some kind of validation code to make sure that the user actually checked something for these things otherwise your application wouldn't work in an ordinary fashion. You'd have to put that somewhere in the Start Button, you probably have to reset those values on and on and on. Much easier just to click on the obvious default choice for rb_one and I think we could find a property here, there it is checked. We'll set check to true, that means the default value when the form opens is that this radio button will be checked and because they're mutually exclusive, if the user decides to pick anything else it will always have something checked. There's no way for the user to uncheck without making sure that something else is checked. Let's do the same thing here for flash. So flash will be the default value so when they open it up the default interval would be 1, the default notification action will be flash and that's that. Okay let's run it and see what happens. We can go up to debug and click start and there's our application with the interval set to 1, the notification action set to flash. Let's start it, looks like the server is running and let's see if the last access time re-increments every 6 seconds. As we're looking at it, nothing's happening, looks like we're doing kind of the right things here but although we got last access time, the time is not incrementing, now remember it should be incrementing every 6 seconds. Let's stop the timer, it doesn't do anything that's apparent. Let's exit the application, it looks like we have some debugging to do.

Tutorial Information

Course: Microsoft Visual Studio .NET
Author: Dave Mercer
SKU: 33420
ISBN: 1932072276
Release Date: 2003-04-01
Duration: 7 hrs / 101 lessons
Work Files: Yes
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available