Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2007, 09:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default threads: diferences between sleep and spinwait...

hi guys (and gals)...

I know how threading works, but never try threads in .net. I need a thread to alert some problems that may occurs in the system. The system is a restaurant/pub manager, and the alert system will yell when some product is not out from the kitchen in the specific time. I run this thread to let the user be in any state in the system and not in any specific screen. I'm using BeginCriticalRegion to avoid the thread to abort in the middle of the procces, but i'm not sure (and cannot find any documentation) that this will avoid the main thread to run in the middle of this. Also I don't want this thread to run every second, just every minute or user time defined. So I have spinwait and sleep, that seems to be doing the same, but maybe underliying do diferents things..

Anyone used this?? has any good (real good) doc about this? I will not having problems with deadlocks, but I will have problems with race conditions, since if the table is ocuppied by people and the products not delivered, this thread could try to inform that the table is in alert, and at the same time it could be closed by the manager (or whoever is in charge).. so maybe a closed table will end alerted when it should be closed...

Thanks for reading.. :)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old September 21st, 2007, 09:17 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Have you looked at MSDN yet?

-Peter
 
Old September 21st, 2007, 09:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

yet but the info there seems to be somehow obscure...
A critical section of a thread usually avoids other threads to be running in the same time of your threads, not letting the cpu running others proccess that may affect yours..
but MSDN talk about:
Quote:
quote:
Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain.
is telling about aborting, something like if this thread fails it will cancel the others thread running to avoid system problems.. nothing about the code...
C# has a lock option (that I'm still trying to understand), that will avoid another thread entering a critical region until this object is released by the thread.. any one know the vb function for that option??
spinwait definition:
Quote:
quote:Causes a thread to wait the number of times defined by the iterations parameter.
sleep definition:
Quote:
quote:Blocks the current thread for the specified number of milliseconds.
maybe the diference between them is in the Micro and spinwait will be faster?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
sleep in xsl sunnn XSLT 1 July 2nd, 2008 12:22 PM
How do you put a thread to sleep? BrianWren Pro VB 6 10 April 8th, 2008 11:28 AM
vba access something like sleep ... but not quite. oca.cheleu Access VBA 1 September 5th, 2006 07:07 AM
How to Pause or sleep the background worker thread mks033 C# 2005 0 May 3rd, 2006 07:03 AM
Problems with threads. Threads disappearing? DriesNeyrinck VB.NET 0 June 10th, 2003 08:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.