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 / .NET Framework / Performance / September 2003

Tip: Looking for answers? Try searching our database.

multiple threads and events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francisco K. do Amaral - 22 Sep 2003 19:19 GMT
Hi I'm working with threads and events. Several threads of a method in my
code can launch a event that will be captured by only one component (another
class).
This is a problem to me?? There is a stack of events that will be executed
sequentially??

Thanks.
Stephen Martin - 22 Sep 2003 21:40 GMT
From this perspective an event is really no different from any other method.
There is no automatic synchronization on the event (i.e. no stack of
events) - so an event procedure can be executing on more than one thread at
the same time. As with all methods the local variables and parameters will
be created on the thread's stack and so will be safe from any threading
effects. But if you are accessing any module level (or global) variables or
non-threadsafe methods in your event procedure or if any of the local
variables refer (directly or indirectly) to a module level object then you
must use normal thread synchronization techniques, such as events, mutexes
or locks, to guard against race conditions and invalid data structures, etc.

> Hi I'm working with threads and events. Several threads of a method in my
> code can launch a event that will be captured by only one component (another
[quoted text clipped - 8 lines]
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.520 / Virus Database: 318 - Release Date: 18/9/2003
msnews.microsoft.com - 23 Sep 2003 05:05 GMT
As an interesting aside to this:  If you set timers to run methods in your
app, you should really lock that method unless you are absolutely certain
nothing bad could happen.  If you put that method in a lock (this) block
you're safe and the requests just stack up and wait in line.  On the
off-chance that the timer cycles while you're still executing the method it
could be quite ugly.  I guess I never thought of a timer being a
multi-threaded operation but I learned the hard way.

Wes

> From this perspective an event is really no different from any other method.
> There is no automatic synchronization on the event (i.e. no stack of
[quoted text clipped - 20 lines]
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.520 / Virus Database: 318 - Release Date: 18/9/2003
Francisco K. do Amaral - 25 Sep 2003 17:45 GMT
Ok, I understand that the method that handle the event will execute in the
same context of the thread that lauch it.
So, how can I make the handle method to be another thread?

thanks.

> From this perspective an event is really no different from any other method.
> There is no automatic synchronization on the event (i.e. no stack of
[quoted text clipped - 20 lines]
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.520 / Virus Database: 318 - Release Date: 18/9/2003

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.