gormly
asked on
run a process in the background
I made a simple VB program to update my WAN IP address to an FTP website.
so I can access my home machine from work.
I didn't want to pay for commercial software for something so simple as this.
I am stubborn that way (and yes.. cheap!)
It is working well but I do not know how to make it "run in the background"
I need it to update every 15 minutes, but I am using a timer and it doesn't seem like the right thing to do. It does it's thing but seems to interupt my mouse and other functions for a few seconds.
How can I make a routine work in the background every fifteen minutes without affecting other applications?
Note: I am probably going to change it so it updates only when the wan ip is different but I still need to make it work in the background.
so I can access my home machine from work.
I didn't want to pay for commercial software for something so simple as this.
I am stubborn that way (and yes.. cheap!)
It is working well but I do not know how to make it "run in the background"
I need it to update every 15 minutes, but I am using a timer and it doesn't seem like the right thing to do. It does it's thing but seems to interupt my mouse and other functions for a few seconds.
How can I make a routine work in the background every fifteen minutes without affecting other applications?
Note: I am probably going to change it so it updates only when the wan ip is different but I still need to make it work in the background.
'If you want to watch the status..you can add this line in the Timer right underneath this line::
>>> under this line add below:: currentTick = currentTick + 1
Label1.Caption = modMinutes - currentTick & " minutes left"
Which will return the number of minutes left until the execution of your function.
This would be useful only for testing purposes...so you can get an idea of when the command will be launched
>>> under this line add below:: currentTick = currentTick + 1
Label1.Caption = modMinutes - currentTick & " minutes left"
Which will return the number of minutes left until the execution of your function.
This would be useful only for testing purposes...so you can get an idea of when the command will be launched
'The flickering of the mouse is probrably your method of uploading the FTP file which probrably when executes freezes the mouse for a split second...I have a work around this it uses FTP API which is IMHO better then using the inet control and much easier. If you want the upload function just let me know.
ASKER
Hi EGL
Thanks, but I am already using a timer in much the same way (almost exactly the same code) and it does only update every 15 minutes.
The problem isn't getting the timer to work, the problem is getting all this to work in the "background."
You see, when my function is "triggered" by my current timer code , whatever I happen to be working on gets interupted somewhat.. like something else is going on. (the update) It is annoying and I want the ftp update that my program completes to NOT affect any foreground programs or processes, so you see, it is not the timer.. its the function.
I am not a big time programmer, I fiddle around.
I just need to know how to make the function run without affecting any other process.
I thought that was called a "background process"
also
you said:
"Also can I suggest Remote Desktop Connection? This allows you to access your computer from anywere ...Its in start menu / accessories"
No offense, but I just thought that was funny when I read it, you see, the entire reason for writing the Wan IP updater was to use Remote Desktop.
I said: "so I can access my home machine from work", of course, I need to know the IP to connect... right?
LOL, again, no ofense, I just thought that was funny. Thanks for the help.
Thanks, but I am already using a timer in much the same way (almost exactly the same code) and it does only update every 15 minutes.
The problem isn't getting the timer to work, the problem is getting all this to work in the "background."
You see, when my function is "triggered" by my current timer code , whatever I happen to be working on gets interupted somewhat.. like something else is going on. (the update) It is annoying and I want the ftp update that my program completes to NOT affect any foreground programs or processes, so you see, it is not the timer.. its the function.
I am not a big time programmer, I fiddle around.
I just need to know how to make the function run without affecting any other process.
I thought that was called a "background process"
also
you said:
"Also can I suggest Remote Desktop Connection? This allows you to access your computer from anywere ...Its in start menu / accessories"
No offense, but I just thought that was funny when I read it, you see, the entire reason for writing the Wan IP updater was to use Remote Desktop.
I said: "so I can access my home machine from work", of course, I need to know the IP to connect... right?
LOL, again, no ofense, I just thought that was funny. Thanks for the help.
ASKER
egl1044
Heck YEA!
If that is my problem, (and I suspect it is) I would LOVE to have a better snippet than using Inet.. My mouse and process issue is when FTP executes because if I just let the email function go, it doesn't effect anything else, but once I use the ftp option, it causes issues.
that would be fantastic.
Heck YEA!
If that is my problem, (and I suspect it is) I would LOVE to have a better snippet than using Inet.. My mouse and process issue is when FTP executes because if I just let the email function go, it doesn't effect anything else, but once I use the ftp option, it causes issues.
that would be fantastic.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The reason that I declared everything as Private is because It will use alot less memory thus making it a little faster than declaring as public, just a useful tip.
Im sure you already know that all you need to do is add this to form_load, but i will add it anyway
if app.previnstance= true then
end
end if
app.taskvisible=false
form1.hide
if app.previnstance= true then
end
end if
app.taskvisible=false
form1.hide
ASKER
Alright
NO FAIR!
Perfectly executing code that takes care of my problem.
Now I feel guilty.
Wow, that is just fantastic, no more annoying interuptions!!!
This was way 'above and beyong' of what I asked for here, thanks a lot!
NO FAIR!
Perfectly executing code that takes care of my problem.
Now I feel guilty.
Wow, that is just fantastic, no more annoying interuptions!!!
This was way 'above and beyong' of what I asked for here, thanks a lot!
ASKER
one question?
I like this method, but it doesn't sem to overwrite the file that is currently on the server.
Is there a way to make it overwrite?
of delete the old before puting the new?
I like this method, but it doesn't sem to overwrite the file that is currently on the server.
Is there a way to make it overwrite?
of delete the old before puting the new?
ASKER
never mind, I got it.. I was doing something stupid.
It still uses a timer but the timer will execute the function only when it reaches 15 minutes, then it will reset again..
'=========================
Add the following code to the form_declerations section::
'=========================
Private Const modMinutes = 15 'set in minutes when to execute command
Dim currentTick As Integer
'=========================
'In Form_Load add the following code
'=========================
currentTick = 0
Timer1.Enabled = True
Timer1.Interval = 60000
'=========================
Add the following code in a timer::
'=========================
currentTick = currentTick + 1
If currentTick >= modMinutes Then
'Your upload function here or whatever you want to execute in 15 minutes.
debug.print "15 minutes has been reached"
DoEvents
currentTick = 0
End If
Well that should do it...
Also can I suggest Remote Desktop Connection? This allows you to access your computer from anywere ...Its in start menu / accessories
Regards,
EGL