visual studio - C# TopShelf Service runs great with debugging; Incredibly slow without debugging -


edit: still issue program not running slow service, running slow whenever not debugging. running diagnostics withotu debugging produced same slowness. peak cpu usage 3%. being said, why application run slower without debugging incredibly helpful google down answer :)

using c# , nuget'd topshelf, have made filewatcher/mover. there instance of filesystemwatcher performs long set of logic against text document (between 100 kb > 8 mb). reads text document (on unc network location) move lines 1 of 2 output files.

while run application through visual studios 2015 community in debug mode or release mode, file actions , movement instant can get. satisfied, installed application service on same local machine. turn on service, key trigger, , starts moving text files.... 50 kb every couple seconds.

1 mb file taking few minutes parse through when took whopping 10 seconds when run through visual studios. service logged in me, same user in visual studio.

any ideas? have used topshelf 3-4 other services, utilizing filesystemwatcher or system.io.file library (using file library).

i can post code if needed, bunch of if statements iterates through each line of text. key issue being: works great vs, not service. why??

p.s. noticed took >4 minutes move 1.4 mb's file line line, went through logic after move within same second.

i post snippet of topshelf configuration using, not much:

    static void main(string[] args)     {         hostfactory.run(hostconfigurator =>         {             hostconfigurator.service<service>(serviceconfigurator =>             {                 serviceconfigurator.constructusing(name => new asnwatcher());                 serviceconfigurator.whenstarted(tc => tc.start());                 serviceconfigurator.whenstopped(tc => tc.stop());             });             hostconfigurator.runaslocalsystem();              hostconfigurator.setdescription("highrisk asn watcher");             hostconfigurator.setdisplayname("highriskasnwatcher");             hostconfigurator.setservicename("highriskasnwatcher");         });     } 

(yes, says local system, changed post install proper user.)

adding code reading; lite.

i adding piece of code splitting:

     foreach (string line in file.readalllines(fullpath))             {                 if (line.startswith("asiaud"))                 {                     foreach (var field in filehelper856aud.readstring(line))                     {                         if (field.tradeid.trimend() != tradeid && field.tradeid.trimend() != catalogtradeid)                         {                             logger.info("found thistrade id:  " + field.tradeid.trimend());                             thisorder = true;                         }                         else                         {                             logger.info("found thattrade id:  " + field.tradeid.trimend());                             thisorder = false;                         }                     }                 }                 if (thisorder )                 {                     try                     {                          file.appendalltext(newfile1, line + environment.newline);                     }                     catch (exception e)                     {                         //write log,  send email alerting it.                     }                 }                 else                 {                     file.appendalltext(newfile2, line + environment.newline);                 }             }             logger.info("file split complete.  deleting original file...");             file.delete(fullpath); 

i able find hints , in right direction through other stack articles once discovered wasn't service piece hurting it, running without profiler in general.

why program run way faster when enable profiling?

the reason because when run application within visual studio, debugger attached it. when run using profiler, debugger not attached.

if press f5 run program, release build, debugger still attached.

if try running .exe itself, or running program through ide "debug > start without debugging" (or press ctrl+f5) application should run fast profiler.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -