JOHNFROG
asked on
where to start to set up a background process vb.net
I really just need someone to help me understand what is the best way to solve the following problem. Should I build it as a web service maybe - i just dont know.
Basically I would like to build something into my website that routinely checks the database and performs some processing dependent on what it finds. This process should run independently of any user session and it will continue to poll the database while the website is active.
I could write it as a typical web form and run it manually but there must be a way to automate it. I just dont know what it is.
Basically I would like to build something into my website that routinely checks the database and performs some processing dependent on what it finds. This process should run independently of any user session and it will continue to poll the database while the website is active.
I could write it as a typical web form and run it manually but there must be a way to automate it. I just dont know what it is.
Have you considered running a Windows Service (not web)?
ASKER
I want to be able to write the solution up similar to an aspx page with vb code behind, can I write a such a page and then load the url as a windows service? I doubt its that easy. where to look ?
Maybe I misunderstood the question. So do you want some processing to be done while a user has the page visible in their browser, or do you mean while your website exists (meaning not taken offline)?
ASKER
while the website exists. I want to be able to basically set an aspx to run on the server at a specified interval. I am quite capable of writing the code behind but wondering how I would implement it.
Perhaps though I am able to do this using services - thats what I am trying to find out.
Perhaps though I am able to do this using services - thats what I am trying to find out.
ASKER
NOT while the user has the browser session open. behind the scenes stuff
I'm not trying to be a pain here, but I was just thinking that if you wrote a Windows service to run on your web server, it could do the checking/updating to the database. It would run in the background of your server and you could set it up to process on a timer.
This site has a fairly simple demonstration of writing services
http://www.codeproject.com/KB/system/WindowsService.aspx
My main point in suggesting a win service is because you said you want background processing and automation.
This site has a fairly simple demonstration of writing services
http://www.codeproject.com/KB/system/WindowsService.aspx
My main point in suggesting a win service is because you said you want background processing and automation.
ASKER
will have to look at that more closely tomorrow. appreciate your assistance so far.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for that. I would need to convert to VB to make sense of it. But you have given me somewhere to start. should be able to proceed from here
Do you need help with the conversion? I am fluent in both languages :)
ASKER
wow. going above the call of duty. heck if you dont mind then that'll be very welcomed. I was going to get around to it sooner or more likely later.
appreciate ur help.
appreciate ur help.
It's no big deal :) I really enjoy helping people here.
As a tip, make sure to mention which language you're coding in--even if the question doesn't really seem language specific. I, and I'm sure other experts as well, will look for the language an asker references. If I can't find one, then I usually default to whichever language I'm comfortable with (C# in my case). Even if an expert primarily codes in one language, they usually either know how to read/write the other(s) or can figure out how to translate it.
See below for translation :)
As a tip, make sure to mention which language you're coding in--even if the question doesn't really seem language specific. I, and I'm sure other experts as well, will look for the language an asker references. If I can't find one, then I usually default to whichever language I'm comfortable with (C# in my case). Even if an expert primarily codes in one language, they usually either know how to read/write the other(s) or can figure out how to translate it.
See below for translation :)
Imports System.ServiceProcess
Partial Class Service1
Inherits ServiceBase
Private updateTimer As System.Threading.Timer
Private startTime As TimeSpan
Private interval As TimeSpan
Public Sub New()
InitializeComponent()
Me.startTime = New TimeSpan(0)
Me.interval = New TimeSpan(0, 0, 10)
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
Me.updateTimer = New System.Threading.Timer(AddressOf DoUpdate, Nothing, Me.startTime, Me.interval)
End Sub
Protected Overrides Sub OnStop()
Me.updateTimer.Dispose()
End Sub
Private Sub DoUpdate()
Using w As System.IO.StreamWriter = New System.IO.StreamWriter("C:\\out.txt", True)
w.WriteLine(DateTime.Now.ToString())
w.Close()
End Using
End Sub
End Class
ASKER
awesome. thanks for that. you really gone the extra mile.
Makes alot more sense to me now. I will see what I can do with that.
much appreciated.
Makes alot more sense to me now. I will see what I can do with that.
much appreciated.