c# - .net 4.5 Correct Windows Service Start Method -
c# - .net 4.5 Correct Windows Service Start Method -
now tasks seem accepted way of implementing multi-threading, "correct" way write windows service start method?
the start method finish i'm new tasks , want create sure right way implement service work.
i've tested , seems work want know if there side effects approach.
protected override void onstart(string[] args) { task.run(() => myservicethingstodo()); } private void myservicethingstodo() { // stuff want read database, send alerts // start other tasks }
i've looked around @ usual sources , can't find source (msdn or otherwise) states right way build service now.
i've used in enterprise applications , works without issue:
_messagequeuewatcher = new task(_engineservice.startmessagequeuewatcher, _canceltokensource.token, taskcreationoptions.longrunning); _messagequeuewatcher.start();
i run asynchronous phone call off of onstart(string[] args){}
c# .net windows service
Comments
Post a Comment