I have an application that I need to automate where at a certain time each day, say 6pm, it will run a certain method(which is to check a database for key terms and then access the api to search for these terms). But there is also another process which is running all the time accessing the stream api so when the search is complete, it interrupts the stream and hands over the new terms.
Now I thought of adding the .exe file to windows task scheduler but not sure if that would work. The stream method run indefinitely and at 6pm each day another process needs to run. I thought of using the system.threading.task TaskFactory but when I include it, it shows taskfactory as undefined. ( I do have .net framework 4.0)If it launches using the task scheduler as 6pm with my code logic as follows:
While True
'should i run this method as background
dim gStream as StreamProcess
gStream.module1()
If DateTime.Now.TimeOfDay.ToString = searchTime Then
addKeywordSearchRules = getSTerms.getNewTerms(addKeywordSearchRules)
ruleManip.ruleChanges(ruleMethods.Method.ADD, addKeywordSearchRules)
End If
Dim gSearch As SearchProcess
if not addKeywordSearchRules.count = 0 then
gSearch.module1()
end if
End While
Does this logic make sense? Any other ideas>
An alternative would be to use a system.windows.forms.timer object.
i.e do something like the following, assuming your Timer object is called Timer1:
Hope that helps.
EDIT: The following is sample code to make this work in a console application…
The minor differences are:
System.Windows.Forms
declare the timer as WithEvents, so that your module gets notified of the “Tick” event
You can import system.windows.forms by first double-clicking on “My project” in your project explorer, then going to “References”, then clicking on “Add”, then choosing the “.Net” tab and choosing System.windows.forms. I hope those are the right english names, because I am using visual studio in a different language.