C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

CPU Monitor


Posted Date: 14 Sep 2009    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: LaljiMember Level: Diamond    
Rating: 1 out of 5Points: 8



ASPX Code Sample

< %@ Page Language="vb" Inherits="vb_CPUMonitorStyle2" Src="vb_CPUMonitorStyle2.aspx.vb" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html>
< head runat="server">
< style type="text/css">
.gridBg {
background-image:url('images/bg_gray.gif');
width:520px;
height:229px;
overflow:hidden;
}
.graph {
position:relative;
left:37px;
top:15px;
width:467px;
height:199px;
overflow:hidden;
}
.bar {
width:8px;
background-image:url('images/bg_column.gif');
background-repeat:repeat-y;
border-left:1px solid white;
border-top:1px solid white;
font-size:1px;
}

td {
font: 10pt Tahoma;
margin: 20px;
}
.title {
font-size: X-Large;
padding: 20px;
border-bottom: 2px solid gray;
width: 100%;
}
< /style>
< /head>
< title>Server CPU load monitor< /title>
< body>
< form runat="server">
< table border="0">
< tr>
< td valign="top" width="630" colspan="4">
< span class="title">Server CPU load monitor example< /span>< br />< br />< br />
This example takes CPU load value from server side every second and displays it in a bar graph.< br />< br />
< /td>
< /tr>
< tr>
< td>
< div class="gridBg">
< div class="graph">
< table align="right" id="container" cellspacing="0" cellpadding="0" style="height:200px;">< tr>< td valign="bottom" align="right">< div class="bar">< /div>< /td>< /tr>< /table>
< /div>
< /div>
< /td>
< /tr>
< /table>

< script type="text/javascript">
var tr = document.getElementById("container").firstChild.firstChild;
var td = tr.firstChild;
var numBars = 0;

function getResult(val) {
var tmp = td.cloneNode(true);
tmp.firstChild.style.height = (Math.round(val) * 2 + 1) + "px";
tr.appendChild(tmp);

if(numBars > 50)
tr.removeChild(tr.firstChild);
else
numBars++;
}
< /script>
< br />< br />< br />

< a style="font-family:Tahoma;font-size:12px" href="Default.aspx?type=VBNET">« Back to examples< /a>
< /form>
< /body>
< /html>


VB Codebehind Sample

imports System

Public Class vb_CPUMonitorStyle2
Inherits OboutInc.oboutAJAXPage

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

CreateTimer("updateCount", "computeCount", "getResult", 1000)

End Sub

Public Function computeCount() As System.Double

Dim rnd As Random = New Random()
Dim val As System.Double = rnd.Next(4)
If val = 2 Then ' insert a random spike
Return rnd.Next(40)
End If
Return rnd.Next(10)

End Function

End Class



Responses

Author: Shunmuganathan M    17 Sep 2009Member Level: Diamond   Points : 0
Nice code, but But I could not understand..
Please give some discription


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
CPU Monitor  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Yes/No Confirmation Box
Previous Resource: Dealing with timer
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use