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

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -