Efficient implementation of threads in the given scenario

Posted by shadeMe on Stack Overflow See other posts from Stack Overflow or by shadeMe
Published on 2010-05-21T01:22:16Z Indexed on 2010/05/21 1:30 UTC
Read the original article Hit count: 248

I've got a winforms application that is set up in the following manner: 2 buttons, a textbox, a collection K, function X and another function, Y.

  1. Function X parses a large database and enumerates some of its data in the global collection.
  2. Button 1 calls function X.
  3. Function Y walks through the above collection and prints out the data in the textbox.
  4. Button 2 calls function Y.

I'd like to call function X through a worker thread in such a way that:

  1. The form remains responsive to user input. This comes intrinsically from the use of a separate thread.
  2. There is never more than a single instance of function X running at any point in time.
  3. K can be accessed by both functions at all times.

What would be the most efficient implementation of the above environment ?

© Stack Overflow or respective owner

Related posts about clr

Related posts about multithreading