boost - windows service to run a method at definite time interval in C++ -
i want call method periodically in windows service built in c++. calling method in svcmain().
int main(int argc, char* argv[]) { // services run have added in table. // takes service name , name of method called sc manager. // add additional services process table. service_table_entry servicetable[]= {{svcname,(lpservice_main_function)svcmain},{null,null}}; // call returns when service has stopped. // process should terminate when call returns. startservicectrldispatcher(servicetable); return 0; } void winapi svcmain(dword argc, lptstr *argv) { connecttoserver(); }
q1. going fire connecttoserver() time or once? don't know how win service works.
q2.i want connecttoserver() fired every 15 mins. how can ?
edit: how can create installer service?
it's going call svcmain once. you're not doing should in svcmain. there's example on msdn writing servicemain function.
if copy example, you'd write code call connecttoserver inside svcinit function (inside while(1)
loop). can 15 minute delay between calls specifying 15 minutes timeout value in call waitforsingleobject
.
if connecttoserver long running process, should find way of breaking , introducing more calls waitforsingleobject
within it, service responds in timely fashion stop requests.
Comments
Post a Comment