doing some work in the background occasionally

I have an application that needs to perform some background work, i.e. Logging, wich must not block the main thread. How would I basically design such a scenario It is obvious that I should do that on an extra thread but I think it is a bad idea to spawn a new thread everytime a log-message is written and let it die once the message was written. But how do I keep a thread alive and trigger the log-messages and pass the string to that thread Also, should I give that thread a lower priority Maybe there is a best practise for this kind scenario


Answer this question

doing some work in the background occasionally

  • VoiceOfExperience

    Have a look on this too!

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=847014&SiteID=1

    I hope this will help you in getting Started!

    Best Regards,



  • TheJet

    bitbonk wrote:
    How about using the ThreadPool class Doesn't that almost serve the same purpose Only that is not part of the component architecture What are the conceptual differences between the two

    Background Worker is highly recommended to use in performing background tasks if you are using .Net 2.0!

    See MSDN Documents for more details!

    Best Regards,



  • JCakeC

    Use BackgroundWorker Componenet in .Net 2.0 to do any asyncrhonous operation on background without effecting the min thread's execution and your applications performance!

    I hope this will help!

    Best Regards,



  • cheston

    bitbonk wrote:
    Does this apply for console applications, since my application is not a Windows Forms application Also what do you mean by "effecting min thread's execution"

    Yes Background worker can work in anytype of .Net application and sorry for that typing Mistake ""effecting min thread's execution"" I wrote Main's Thread, Means it wont block your application's Main Thread!

    Best Regards,



  • Talonstryk

    Does this apply for console applications, since my application is not a Windows Forms application Also what do you mean by "effecting min thread's execution"

  • thorlax402

    How about using the ThreadPool class Doesn't that almost serve the same purpose Only that is not part of the component architecture What are the conceptual differences between the two

  • doing some work in the background occasionally