M
Matt Douhan
Hello
I have a small VB APP, that runs on on the end users PC, ever n seconds it
connects to a webserver and runs a webpage and stores a local file.
My problem is that it takes way to much resources, when the program is
active the PC becomes almost unusable so I am sure I have missed something,
I want the program to live in the background and do its thing without
affecting the peformance of the users PC.
the code snippet is al follows
Private Sub tmr_main_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmr_main.Tick
Dim byteData() As Byte
Dim intFile As Integer
Dim strURL As Char
Dim cmd As Char
Dim fire As Integer
If chkboxdebugflag = 2 Then
Else
On Error Resume Next
End If
Dim wr As HttpWebRequest =
CType(WebRequest.Create("http://www.fruitsalad.org/people/mdouhan/test/foo.t
xt"), HttpWebRequest)
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Dim str As Stream = ws.GetResponseStream()
Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
Dim fstr As New FileStream("foo.txt", FileMode.OpenOrCreate,
FileAccess.Write)
fstr.Write(inBuf, 0, bytesRead)
str.Close()
fstr.Close()
Dim wrrm As HttpWebRequest =
CType(WebRequest.Create("http://www.fruitsalad.org/people/mdouhan/test/bar.p
hp"), HttpWebRequest)
Dim wsrm As HttpWebResponse = CType(wrrm.GetResponse(), HttpWebResponse)
Dim strrm As Stream = wsrm.GetResponseStream()
' here we need the code to first copy the file to \\%machinename%\zebra but
until I learn how I have to use an ugly .cmd file, maybe someone can help me
' would be nice to have a copy file.txt ltp1 and then del /y file.txt in
this code instead of the cmd file, but I guess thats what I get for being a
newbie
Shell("printit.cmd")
Any help would be great
rgds
Matt
I have a small VB APP, that runs on on the end users PC, ever n seconds it
connects to a webserver and runs a webpage and stores a local file.
My problem is that it takes way to much resources, when the program is
active the PC becomes almost unusable so I am sure I have missed something,
I want the program to live in the background and do its thing without
affecting the peformance of the users PC.
the code snippet is al follows
Private Sub tmr_main_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmr_main.Tick
Dim byteData() As Byte
Dim intFile As Integer
Dim strURL As Char
Dim cmd As Char
Dim fire As Integer
If chkboxdebugflag = 2 Then
Else
On Error Resume Next
End If
Dim wr As HttpWebRequest =
CType(WebRequest.Create("http://www.fruitsalad.org/people/mdouhan/test/foo.t
xt"), HttpWebRequest)
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Dim str As Stream = ws.GetResponseStream()
Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
Dim fstr As New FileStream("foo.txt", FileMode.OpenOrCreate,
FileAccess.Write)
fstr.Write(inBuf, 0, bytesRead)
str.Close()
fstr.Close()
Dim wrrm As HttpWebRequest =
CType(WebRequest.Create("http://www.fruitsalad.org/people/mdouhan/test/bar.p
hp"), HttpWebRequest)
Dim wsrm As HttpWebResponse = CType(wrrm.GetResponse(), HttpWebResponse)
Dim strrm As Stream = wsrm.GetResponseStream()
' here we need the code to first copy the file to \\%machinename%\zebra but
until I learn how I have to use an ugly .cmd file, maybe someone can help me
' would be nice to have a copy file.txt ltp1 and then del /y file.txt in
this code instead of the cmd file, but I guess thats what I get for being a
newbie
Shell("printit.cmd")
Any help would be great
rgds
Matt