New Guy: Threading Info

I'm working on a small server project where I believe I need two threads in a C# application:

1 Thread to handle user interface (Windows Forms) requests

and

1 Thread to perform tasks requested through the user interface against MS SQL Server

Hopefully this is sensible ...

In any event, are there any good articles on multi-threading w/ C# that cover the basics from the ground up  

Thanks!

DB


Answer this question

New Guy: Threading Info

  • Megakemp

    For the SQL server stuff I recommend that you use a thread pool. See ThreadPool.QueueUserWorkItem in MSDN.

    You would then have a thread(s) that synchronously reponds to user requests, and a thread pool that asynchronously runs the tasks against SQL Server.

  • Kismet123

    If I found a problem in C#, my first reference would be .NET Framework SDK documentation, it has threading tutorial for C#. then up to msdn.microsoft.com or www.codeproject.com.
    I don't know if that what you need.

    If You can afford it, C# Threading Handbook published by Apress is a good one.

  • MattH6

    Thanks to everyone for your responses.  Several creative answers, and they will all be helpful!

     

    Doug



  • hssj

    If you're using .NET 2.0 you could use the asynchronous execution model in ADO.NET. This is to prefer if you would like to cancel the SQL operations since the only way to cancel a threedpool thread or a thread executing outside of the CLR; is to force kill it, and that is not recommended.

    Also, for windows forms stuff, I've written an article about handling events and marshalling delegate invocation over different threads.

    http://www.lowendahl.net/content.aspx cshrpContent=csa31



  • New Guy: Threading Info