Re: Write log file using Thread



It sounds like you are talking about having an asynchronous process for logging stuff so that you can return control to the user instead of blocking the UI thread. This might improve perceived performance. But no doubt all you are doing is writing 1 line or so at a time. The overhead of creating a thread probably would not be worth it. As this creation is expensive not to mention you will have to sync the file which causes blocking - and always use the threadpool.

On a side note to good app design:
If you are logging exceptions, have you considered creating an exception interceptor that gets executed when a given exception occurs. There are many frameworks on the desktop that handle this but only one I know about on the CF and that is PostSharp. This is often refered to as cross cutting concerns. You could then use log4net to log data. (there is support for CF)

--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com

<verenadoll@xxxxxxxxx> wrote in message news:c33a5e7d-da84-4363-b0b0-9ccfe199d89f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello Ginny,

thanks for your answer.

Actually my programm execute a function and at the end of the function
i write the duration time to a log file. After that next function was
executed and so on. every time the log file was written, my programm
has to "wait". So i thought using one thread and a queue would get
better performace, because writing the logfile, can be done in
backgroud.

i don´t understand, why this wouldn´t get better performance.

Regards, Verena Doll

.



Relevant Pages

  • Question about DTS error logging
    ... I am using the DTS gui to design & execute)? ... I am logging the insert or transform errors in SqlServer, ... the text log file) like "..insert of x column failed because of NULL .. ...
    (microsoft.public.sqlserver.dts)
  • Re: Logging components?
    ... I think Logging is pretty much individual, so that usualy everyone has their ... {Write Logged exception into the Log file? ... {Write exception with a short string description into the Global App Log ... > By logging components, I specifically DON'T MEAN components for catching ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Phantom /var full messages
    ... if you could isolate it to just snort or just MySQL. ... without restarting the program that's logging to them. ... compresses the current log file into a new file, ...
    (freebsd-questions)
  • Re: Annoying 1202 errors
    ... Enabling this logging tracks all changes and settings applied to the machine ... Name: UserEnvDebugLevel ... I recommend that you remove any existing log file and then use gpupdate ... feature GUEST. ...
    (microsoft.public.win2000.group_policy)
  • Re: Theodore Adorno, a prophet of data systems design
    ... >> Can you translate the above into English please? ... > at compile time or runtime, up to you) what level of logging you wish. ... >> a single log file from multiple threads for anyone with even a beginner's ... > Actually, I can't guarantee that it will work in a multithreaded program, ...
    (comp.programming)