Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Queuing Up Threads - Thread Works Until Needing Resource From Other     Thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jehugaleahsa@gmail.com - 14 Mar 2008 05:15 GMT
Hello:

At work we have run into an interesting "need". We have a bunch of
customers whose calculations affect one another. Now, to this time, we
have never and we may never have a scenario where two customers affect
one another. So, right now, our system can handle A affecting B.
However, we may someday need to handle A affects B and B affects A. Of
course, neither need to be totally calculated for the other to run.

Ideally, it would be nice to have a list or queue of customers, each
calculating in a different thread. At some deterministic point in a
customer's calculation, we would check to see if they are affected. It
would be nice to tell the thread to simply STOP. We could simply place
the paused thread at the back of the queue. Whenever its turn came
around again, it would be "guarunteed" that it could progress, so we
just unpause it.

In the current system we have to do a long, slow SQL to order
customers. However, this ordering doesn't handle inner-dependencies. I
would like to try to replace the slow SQL with this method, gaining
the benefit of solving the inner-dependency issue at the same time.

The only negative of doing things this way is the memory sitting
around in the inactive, partially completed thread. However, due to
some refactoring, my code only generates a very small memory footprint
until later in the calculation. Also, the number of inner-dependencies
will be small, so that isn't an issue (today).

How can I achieve my goal? Is there a way of doing this without
identifying the affecting customer? I just want to keep it simple by
putting the paused thread after all other threads. if it's not that
simple, let me know.

Thanks,
Travis
DrewCE - 14 Mar 2008 05:35 GMT
I don't exactly follow what you are trying to do, but there are many ways to
pause a thread until something tells it to start again.

For instance, look up AutoResetEvent...
http://msdn2.microsoft.com/en-us/library/system.threading.autoresetevent.aspx

...or ManualResetEvent...
http://msdn2.microsoft.com/en-us/library/system.threading.manualresetevent.aspx

...or WaitHandle.WaitAll and WaitHandle.WaitAny...
http://msdn2.microsoft.com/en-us/library/system.threading.waithandle.aspx

Take a peak at those and see if they are along the lines of what you are
looking for.

-Drew

> Hello:
>
[quoted text clipped - 31 lines]
> Thanks,
> Travis
William Stacey [C# MVP] - 15 Mar 2008 02:48 GMT
You may also have a look at the CCR library in the ms robotics sdk.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.